-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
Makefile
120 lines (103 loc) · 3.74 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Find documentation in README.md under
# the heading "Makefile Options".
OPENWISP_VERSION = 24.11.1
SHELL := /bin/bash
.SILENT: clean pull start stop
default: compose-build
USER = registry.gitlab.com/openwisp/docker-openwisp
TAG = edge
SKIP_PULL ?= false
SKIP_BUILD ?= false
SKIP_TESTS ?= false
# Pull
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-websocket' ; do \
docker pull --quiet $(USER)/$${image}:$(TAG); \
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 ./images/openwisp_base/Dockerfile \
--target SYSTEM ./images/; \
docker build --tag openwisp/openwisp-base:intermedia-python \
--file ./images/openwisp_base/Dockerfile \
--target PYTHON ./images/ \
$$BUILD_ARGS; \
docker build --tag openwisp/openwisp-base:latest \
--file ./images/openwisp_base/Dockerfile ./images/ \
$$BUILD_ARGS
nfs-build:
docker build --tag openwisp/openwisp-nfs:latest \
--file ./images/openwisp_nfs/Dockerfile ./images/
compose-build: base-build
docker compose build --parallel
# Test
runtests: develop-runtests
docker compose stop
develop-runtests:
docker compose up -d
make develop-pythontests
develop-pythontests:
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
start:
if [ "$(SKIP_PULL)" == "false" ]; then \
make pull; \
fi
printf '\e[1;34m%-6s\e[m\n' "Starting Services..."
docker --log-level WARNING compose 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 --log-level ERROR compose stop
docker --log-level ERROR compose down --remove-orphans
docker compose down --remove-orphans &> /dev/null
# Publish
publish:
if [[ "$(SKIP_BUILD)" == "false" ]]; then \
make compose-build nfs-build; \
fi
if [[ "$(SKIP_TESTS)" == "false" ]]; then \
make runtests; \
fi
for image in 'openwisp-base' 'openwisp-nfs' 'openwisp-api' 'openwisp-dashboard' \
'openwisp-freeradius' 'openwisp-nginx' 'openwisp-openvpn' 'openwisp-postfix' \
'openwisp-websocket' ; do \
# Docker images built locally are tagged "latest" by default. \
# This script updates the tag of each built image to a user-defined tag \
# and pushes the newly tagged image to a Docker registry under the user's namespace. \
docker tag openwisp/$${image}:latest $(USER)/$${image}:$(TAG); \
docker push $(USER)/$${image}:$(TAG); \
if [ "$(TAG)" != "latest" ]; then \
docker rmi $(USER)/$${image}:$(TAG); \
fi; \
done
release:
make publish TAG=latest SKIP_TESTS=true
make publish TAG=$(OPENWISP_VERSION) SKIP_BUILD=true SKIP_TESTS=true