-
-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (115 loc) · 4.35 KB
/
Makefile
File metadata and controls
134 lines (115 loc) · 4.35 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Find documentation in README.md under
# the heading "Makefile Options".
# The .env file can override ?= variables in the Makefile (e.g. OPENWISP_VERSION, IMAGE_OWNER)
include .env
# RELEASE_VERSION: version string used when tagging a new release.
RELEASE_VERSION = $(shell cat images/common/openwisp/VERSION)
SHELL := /bin/bash
.SILENT: clean pull start stop
default: compose-build
USER = registry.gitlab.com/openwisp/docker-openwisp
TAG = edge
# OPENWISP_VERSION: image tag used for pulling/pushing images (e.g. "edge", "latest", "25.10.0")
# Can be overridden via .env or command line. Not the same as RELEASE_VERSION
OPENWISP_VERSION ?= edge
IMAGE_OWNER ?= openwisp
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}:$(OPENWISP_VERSION); \
docker tag $(USER)/$${image}:$(OPENWISP_VERSION) $(IMAGE_OWNER)/$${image}:$(OPENWISP_VERSION); \
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 openwisp_python ./images/ \
$$BUILD_ARGS; \
docker build --tag $(IMAGE_OWNER)/openwisp-base:$(OPENWISP_VERSION) \
--file ./images/openwisp_base/Dockerfile \
$$BUILD_ARGS \
./images/
nfs-build:
docker build --tag $(IMAGE_OWNER)/openwisp-nfs:$(OPENWISP_VERSION) \
--file ./images/openwisp_nfs/Dockerfile ./images/
compose-build: base-build
docker compose build --parallel
# Test
runtests:
make 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:intermedia-system \
openwisp/openwisp-base:intermedia-python \
$(IMAGE_OWNER)/openwisp-base:$(OPENWISP_VERSION) \
$(IMAGE_OWNER)/openwisp-nfs:$(OPENWISP_VERSION) \
`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 tag $(IMAGE_OWNER)/$${image}:$(OPENWISP_VERSION) $(USER)/$${image}:$(TAG); \
docker push $(USER)/$${image}:$(TAG); \
if [ "$(TAG)" != "latest" ]; then \
docker rmi $(USER)/$${image}:$(TAG); \
fi; \
done
release:
make publish TAG=latest OPENWISP_VERSION=$(RELEASE_VERSION) SKIP_TESTS=true
make publish TAG=$(RELEASE_VERSION) OPENWISP_VERSION=$(RELEASE_VERSION) SKIP_BUILD=true SKIP_TESTS=true
bump:
@if [ -z "$(VERSION)" ]; then \
echo "ERROR: VERSION parameter required. Usage: make bump VERSION=X.Y.Z"; \
exit 1; \
fi
python build.py bump-version "$(VERSION)"