forked from openwisp/docker-openwisp
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
103 lines (89 loc) · 3.45 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Find documentation in README.md under
# the heading "Makefile Options".
SHELL := /bin/bash
.SILENT: clean pull start stop
default: compose-build
# Pull
USER = registry.gitlab.com/openwisp/docker-openwisp
TAG = latest
pull:
printf '\e[1;34m%-6s\e[m\n' "Downloading OpenWISP images..."
for image in 'openwisp-base' 'openwisp-nfs' 'openwisp-api' 'openwisp-dashboard' \
'openwisp-freeradius' 'openwisp-nginx' 'openwisp-openvpn' 'openwisp-postfix' \
'openwisp-radius' 'openwisp-websocket' ; do \
docker pull --quiet $(USER)/$${image}:$(TAG) &> /dev/null; \
docker tag $(USER)/$${image}:$(TAG) openwisp/$${image}:latest; \
done
# Build
python-build: build.py
python build.py change-secret-key
base-build:
BUILD_ARGS_FILE=$$(cat .build.env 2>/dev/null); \
for build_arg in $$BUILD_ARGS_FILE; do \
BUILD_ARGS+=" --build-arg $$build_arg"; \
done; \
docker build --tag openwisp/openwisp-base:intermedia-system \
--file ./build/openwisp_base/Dockerfile \
--target SYSTEM ./build/; \
docker build --tag openwisp/openwisp-base:intermedia-python \
--file ./build/openwisp_base/Dockerfile \
--target PYTHON ./build/ \
$$BUILD_ARGS; \
docker build --tag openwisp/openwisp-base:latest \
--file ./build/openwisp_base/Dockerfile ./build/ \
$$BUILD_ARGS
nfs-build:
docker build --tag openwisp/openwisp-nfs:latest \
--file ./build/openwisp_nfs/Dockerfile ./build/
compose-build: base-build
docker-compose build --parallel
# Test
runtests: develop-runtests
docker-compose stop
develop-runtests:
docker-compose up -d
python3 tests/runtests.py
# Development
develop: compose-build
docker-compose up -d
docker-compose logs -f
# Clean
clean:
printf '\e[1;34m%-6s\e[m\n' "Removing docker-openwisp..."
docker-compose stop &> /dev/null
docker-compose down --remove-orphans --volumes --rmi all &> /dev/null
docker-compose rm -svf &> /dev/null
docker rmi --force openwisp/openwisp-base:latest \
openwisp/openwisp-base:intermedia-system \
openwisp/openwisp-base:intermedia-python \
openwisp/openwisp-nfs:latest \
`docker images -f "dangling=true" -q` \
`docker images | grep openwisp/docker-openwisp | tr -s ' ' | cut -d ' ' -f 3` &> /dev/null
# Production
USER = registry.gitlab.com/openwisp/docker-openwisp
TAG = latest
start: pull
printf '\e[1;34m%-6s\e[m\n' "Starting Services..."
docker-compose --log-level WARNING up -d
printf '\e[1;32m%-6s\e[m\n' "Success: OpenWISP should be available at your dashboard domain in 2 minutes."
stop:
printf '\e[1;31m%-6s\e[m\n' "Stopping OpenWISP services..."
docker-compose --log-level ERROR stop
docker-compose --log-level ERROR down --remove-orphans
docker-compose down --remove-orphans &> /dev/null
# Publish
USER = registry.gitlab.com/openwisp/docker-openwisp
TAG = latest
publish: compose-build runtests nfs-build
for image in 'openwisp-base' 'openwisp-nfs' 'openwisp-api' 'openwisp-dashboard' \
'openwisp-freeradius' 'openwisp-nginx' 'openwisp-openvpn' 'openwisp-postfix' \
'openwisp-radius' 'openwisp-websocket' ; do \
docker tag openwisp/$${image}:latest $(USER)/$${image}:$(TAG); \
docker push $(USER)/$${image}:$(TAG); \
docker rmi $(USER)/$${image}:$(TAG); \
if [[ "$(TAG)" != "edge" ]] && [[ "$(TAG)" != "latest" ]]; then \
docker tag openwisp/$${image}:latest $(USER)/$${image}:latest; \
docker push $(USER)/$${image}:latest; \
docker rmi $(USER)/$${image}:latest; \
fi \
done