Skip to content

Commit 67bfbc0

Browse files
Merge branch 'master' into issues/572-vpn-name-supervisord
2 parents c434949 + 76cd872 commit 67bfbc0

17 files changed

Lines changed: 106 additions & 52 deletions

File tree

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
# Essential
55
DASHBOARD_DOMAIN=dashboard.openwisp.org
66
API_DOMAIN=api.openwisp.org
7+
# Image tag pinning
8+
IMAGE_OWNER=openwisp
9+
# OPENWISP_VERSION: Image tag version (e.g., "25.10.0", "latest", or "edge")
10+
OPENWISP_VERSION=edge
711
# SSH Credentials Configurations
812
SSH_PRIVATE_KEY_PATH=/home/openwisp/.ssh/id_ed25519
913
SSH_PUBLIC_KEY_PATH=/home/openwisp/.ssh/id_ed25519.pub

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
# echo "$DOCKER_HUB_SECRET" | docker login --username "$DOCKER_HUB_USERNAME" --password-stdin
9191
- name: Login to Docker Hub
9292
if: ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
93-
uses: docker/login-action@v3
93+
uses: docker/login-action@v4
9494
with:
9595
username: ${{ secrets.DOCKER_HUB_USERNAME }}
9696
password: ${{ secrets.DOCKER_HUB_SECRET }}
@@ -105,7 +105,7 @@ jobs:
105105

106106
- name: Login to GitLab Container Registry
107107
if: ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/master' }}
108-
uses: docker/login-action@v3
108+
uses: docker/login-action@v4
109109
with:
110110
registry: registry.gitlab.com
111111
username: ${{ secrets.GITLAB_DOCKER_REGISTRY_USER }}

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
# the following action is equivalent to
2828
# echo "$DOCKER_HUB_SECRET" | docker login --username "$DOCKER_HUB_USERNAME" --password-stdin
2929
- name: Login to Docker Hub
30-
uses: docker/login-action@v3
30+
uses: docker/login-action@v4
3131
with:
3232
username: ${{ secrets.DOCKER_HUB_USERNAME }}
3333
password: ${{ secrets.DOCKER_HUB_SECRET }}
@@ -37,7 +37,7 @@ jobs:
3737
make release USER=docker.io/openwisp
3838
3939
- name: Login to GitLab Container Registry
40-
uses: docker/login-action@v3
40+
uses: docker/login-action@v4
4141
with:
4242
registry: registry.gitlab.com
4343
username: ${{ secrets.GITLAB_DOCKER_REGISTRY_USER }}

Makefile

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
# Find documentation in README.md under
22
# the heading "Makefile Options".
33

4-
OPENWISP_VERSION = 25.10.0
4+
# The .env file can override ?= variables in the Makefile (e.g. OPENWISP_VERSION, IMAGE_OWNER)
5+
include .env
6+
7+
# RELEASE_VERSION: version string used when tagging a new release.
8+
RELEASE_VERSION = 25.10.0
59
SHELL := /bin/bash
610
.SILENT: clean pull start stop
711

812
default: compose-build
913

1014
USER = registry.gitlab.com/openwisp/docker-openwisp
1115
TAG = edge
16+
# OPENWISP_VERSION: image tag used for pulling/pushing images (e.g. "edge", "latest", "25.10.0")
17+
# Can be overridden via .env or command line. Not the same as RELEASE_VERSION
18+
OPENWISP_VERSION ?= edge
19+
IMAGE_OWNER ?= openwisp
1220
SKIP_PULL ?= false
1321
SKIP_BUILD ?= false
1422
SKIP_TESTS ?= false
@@ -19,8 +27,8 @@ pull:
1927
for image in 'openwisp-base' 'openwisp-nfs' 'openwisp-api' 'openwisp-dashboard' \
2028
'openwisp-freeradius' 'openwisp-nginx' 'openwisp-openvpn' 'openwisp-postfix' \
2129
'openwisp-websocket' ; do \
22-
docker pull --quiet $(USER)/$${image}:$(TAG); \
23-
docker tag $(USER)/$${image}:$(TAG) openwisp/$${image}:latest; \
30+
docker pull --quiet $(USER)/$${image}:$(OPENWISP_VERSION); \
31+
docker tag $(USER)/$${image}:$(OPENWISP_VERSION) $(IMAGE_OWNER)/$${image}:$(OPENWISP_VERSION); \
2432
done
2533

2634
# Build
@@ -39,12 +47,12 @@ base-build:
3947
--file ./images/openwisp_base/Dockerfile \
4048
--target PYTHON ./images/ \
4149
$$BUILD_ARGS; \
42-
docker build --tag openwisp/openwisp-base:latest \
50+
docker build --tag $(IMAGE_OWNER)/openwisp-base:$(OPENWISP_VERSION) \
4351
--file ./images/openwisp_base/Dockerfile ./images/ \
4452
$$BUILD_ARGS
4553

4654
nfs-build:
47-
docker build --tag openwisp/openwisp-nfs:latest \
55+
docker build --tag $(IMAGE_OWNER)/openwisp-nfs:$(OPENWISP_VERSION) \
4856
--file ./images/openwisp_nfs/Dockerfile ./images/
4957

5058
compose-build: base-build
@@ -72,10 +80,10 @@ clean:
7280
docker compose stop &> /dev/null
7381
docker compose down --remove-orphans --volumes --rmi all &> /dev/null
7482
docker compose rm -svf &> /dev/null
75-
docker rmi --force openwisp/openwisp-base:latest \
76-
openwisp/openwisp-base:intermedia-system \
83+
docker rmi --force openwisp/openwisp-base:intermedia-system \
7784
openwisp/openwisp-base:intermedia-python \
78-
openwisp/openwisp-nfs:latest \
85+
$(IMAGE_OWNER)/openwisp-base:$(OPENWISP_VERSION) \
86+
$(IMAGE_OWNER)/openwisp-nfs:$(OPENWISP_VERSION) \
7987
`docker images -f "dangling=true" -q` \
8088
`docker images | grep openwisp/docker-openwisp | tr -s ' ' | cut -d ' ' -f 3` &> /dev/null
8189

@@ -105,16 +113,13 @@ publish:
105113
for image in 'openwisp-base' 'openwisp-nfs' 'openwisp-api' 'openwisp-dashboard' \
106114
'openwisp-freeradius' 'openwisp-nginx' 'openwisp-openvpn' 'openwisp-postfix' \
107115
'openwisp-websocket' ; do \
108-
# Docker images built locally are tagged "latest" by default. \
109-
# This script updates the tag of each built image to a user-defined tag \
110-
# and pushes the newly tagged image to a Docker registry under the user's namespace. \
111-
docker tag openwisp/$${image}:latest $(USER)/$${image}:$(TAG); \
116+
docker tag $(IMAGE_OWNER)/$${image}:$(OPENWISP_VERSION) $(USER)/$${image}:$(TAG); \
112117
docker push $(USER)/$${image}:$(TAG); \
113118
if [ "$(TAG)" != "latest" ]; then \
114119
docker rmi $(USER)/$${image}:$(TAG); \
115120
fi; \
116121
done
117122

118123
release:
119-
make publish TAG=latest SKIP_TESTS=true
120-
make publish TAG=$(OPENWISP_VERSION) SKIP_BUILD=true SKIP_TESTS=true
124+
make publish TAG=latest OPENWISP_VERSION=$(RELEASE_VERSION) SKIP_TESTS=true
125+
make publish TAG=$(RELEASE_VERSION) OPENWISP_VERSION=$(RELEASE_VERSION) SKIP_BUILD=true SKIP_TESTS=true

deploy/auto-install.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ apt_dependenices_setup() {
5959
}
6060

6161
get_version_from_user() {
62-
echo -ne ${GRN}"OpenWISP Version (leave blank for latest): "${NON}
62+
echo -ne "${GRN}OpenWISP Version (leave blank for latest stable release): ${NON}"
6363
read openwisp_version
6464
if [[ -z "$openwisp_version" ]]; then
6565
openwisp_version=$(curl -L --silent https://api.github.com/repos/openwisp/docker-openwisp/releases/latest | jq -r .tag_name)
@@ -128,7 +128,7 @@ setup_docker_openwisp() {
128128

129129
cd $INSTALL_PATH &>>$LOG_FILE
130130
check_status $? "docker-openwisp download failed."
131-
echo $openwisp_version >$INSTALL_PATH/VERSION
131+
set_env "OPENWISP_VERSION" "$openwisp_version"
132132

133133
if [[ ! -f "$env_path" ]]; then
134134
# Dashboard Domain
@@ -179,7 +179,7 @@ setup_docker_openwisp() {
179179
start_step "Configuring docker-openwisp..."
180180
report_ok
181181
start_step "Starting images docker-openwisp (this will take a while)..."
182-
make start TAG=$(cat $INSTALL_PATH/VERSION) -C $INSTALL_PATH/ &>>$LOG_FILE
182+
make start -C $INSTALL_PATH/ &>>$LOG_FILE
183183
check_status $? "Starting openwisp failed."
184184
}
185185

@@ -192,7 +192,7 @@ upgrade_docker_openwisp() {
192192

193193
cd $INSTALL_PATH &>>$LOG_FILE
194194
check_status $? "docker-openwisp download failed."
195-
echo $openwisp_version >$INSTALL_PATH/VERSION
195+
set_env "OPENWISP_VERSION" "$openwisp_version"
196196

197197
start_step "Configuring docker-openwisp..."
198198
for config in $(grep '=' $ENV_BACKUP | cut -f1 -d'='); do
@@ -202,7 +202,7 @@ upgrade_docker_openwisp() {
202202
report_ok
203203

204204
start_step "Starting images docker-openwisp (this will take a while)..."
205-
make start TAG=$(cat $INSTALL_PATH/VERSION) -C $INSTALL_PATH/ &>>$LOG_FILE
205+
make start -C $INSTALL_PATH/ &>>$LOG_FILE
206206
check_status $? "Starting openwisp failed."
207207
}
208208

docker-compose.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ x-celery-depends-on: &celery-depends-on
1212

1313
services:
1414
dashboard:
15-
image: openwisp/openwisp-dashboard:latest
15+
image: openwisp/openwisp-dashboard:${OPENWISP_VERSION:-edge}
1616
restart: always
1717
build:
1818
context: images
1919
dockerfile: openwisp_dashboard/Dockerfile
2020
args:
2121
DASHBOARD_APP_PORT: 8000
22+
OPENWISP_VERSION: ${OPENWISP_VERSION:-edge}
2223
env_file:
2324
- .env
2425
volumes:
@@ -35,13 +36,14 @@ services:
3536
- influxdb
3637

3738
api:
38-
image: openwisp/openwisp-api:latest
39+
image: openwisp/openwisp-api:${OPENWISP_VERSION:-edge}
3940
restart: always
4041
build:
4142
context: images
4243
dockerfile: openwisp_api/Dockerfile
4344
args:
4445
API_APP_PORT: 8001
46+
OPENWISP_VERSION: ${OPENWISP_VERSION:-edge}
4547
env_file:
4648
- .env
4749
volumes:
@@ -55,13 +57,14 @@ services:
5557
- dashboard
5658

5759
websocket:
58-
image: openwisp/openwisp-websocket:latest
60+
image: openwisp/openwisp-websocket:${OPENWISP_VERSION:-edge}
5961
restart: always
6062
build:
6163
context: images
6264
dockerfile: openwisp_websocket/Dockerfile
6365
args:
6466
WEBSOCKET_APP_PORT: 8002
67+
OPENWISP_VERSION: ${OPENWISP_VERSION:-edge}
6568
env_file:
6669
- .env
6770
volumes:
@@ -70,7 +73,7 @@ services:
7073
- dashboard
7174

7275
celery:
73-
image: openwisp/openwisp-dashboard:latest
76+
image: openwisp/openwisp-dashboard:${OPENWISP_VERSION:-edge}
7477
restart: always
7578
environment:
7679
- MODULE_NAME=celery
@@ -85,7 +88,7 @@ services:
8588
network_mode: "${CELERY_SERVICE_NETWORK_MODE-service:openvpn}"
8689

8790
celery_monitoring:
88-
image: openwisp/openwisp-dashboard:latest
91+
image: openwisp/openwisp-dashboard:${OPENWISP_VERSION:-edge}
8992
restart: always
9093
environment:
9194
- MODULE_NAME=celery_monitoring
@@ -99,7 +102,7 @@ services:
99102
network_mode: "${CELERY_SERVICE_NETWORK_MODE-service:openvpn}"
100103

101104
celerybeat:
102-
image: openwisp/openwisp-dashboard:latest
105+
image: openwisp/openwisp-dashboard:${OPENWISP_VERSION:-edge}
103106
restart: always
104107
environment:
105108
- MODULE_NAME=celerybeat
@@ -113,7 +116,7 @@ services:
113116
- dashboard
114117

115118
nginx:
116-
image: openwisp/openwisp-nginx:latest
119+
image: openwisp/openwisp-nginx:${OPENWISP_VERSION:-edge}
117120
restart: always
118121
build:
119122
context: images
@@ -140,7 +143,7 @@ services:
140143
- websocket
141144

142145
freeradius:
143-
image: openwisp/openwisp-freeradius:latest
146+
image: openwisp/openwisp-freeradius:${OPENWISP_VERSION:-edge}
144147
restart: always
145148
build:
146149
context: images
@@ -156,7 +159,7 @@ services:
156159
- dashboard
157160

158161
postfix:
159-
image: openwisp/openwisp-postfix:latest
162+
image: openwisp/openwisp-postfix:${OPENWISP_VERSION:-edge}
160163
restart: always
161164
build:
162165
context: images
@@ -167,7 +170,7 @@ services:
167170
- openwisp_certs:/etc/ssl/mail
168171

169172
openvpn:
170-
image: openwisp/openwisp-openvpn:latest
173+
image: openwisp/openwisp-openvpn:${OPENWISP_VERSION:-edge}
171174
restart: on-failure
172175
build:
173176
context: images

docs/developer/instructions.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ Makefile Options
114114

115115
Most commonly used:
116116

117-
- ``make start [USER=docker-username] [TAG=image-tag]``: Start OpenWISP
118-
containers on your server.
119-
- ``make pull [USER=docker-username] [TAG=image-tag]``: Pull images from
120-
the registry.
117+
- ``make start [IMAGE_OWNER=docker-username] [OPENWISP_VERSION=version]``:
118+
Start OpenWISP containers on your server.
119+
- ``make pull [IMAGE_OWNER=docker-username] [OPENWISP_VERSION=version]``:
120+
Pull images from the registry.
121121
- ``make stop``: Stop OpenWISP containers on your server.
122122
- ``make develop``: Bundle all the commands required to build the images
123123
and run containers.
@@ -128,8 +128,8 @@ Most commonly used:
128128

129129
Other options:
130130

131-
- ``make publish [USER=docker-username] [TAG=image-tag]``: Build, test,
132-
and publish images.
131+
- ``make publish [IMAGE_OWNER=docker-username]
132+
[OPENWISP_VERSION=version]``: Build, test, and publish images.
133133
- ``make python-build``: Generate a random Django secret and set it in the
134134
``.env`` file.
135135
- ``make nfs-build``: Build the OpenWISP NFS server image.

docs/user/settings.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ Essential
3737
You will need to adapt these values to get the docker images working
3838
properly on your system.
3939

40+
.. _openwisp_version:
41+
42+
``OPENWISP_VERSION``
43+
~~~~~~~~~~~~~~~~~~~~
44+
45+
- **Explanation:** The version of OpenWISP to use. It can be set to a
46+
specific version (e.g. ``25.10.0``) or to ``edge`` to always use the
47+
latest development version.
48+
- **Valid Values:** ``edge``, ``latest``, or a semantic version string
49+
(e.g., ``25.10.0``)
50+
- **Default:** ``edge``
51+
4052
.. _dashboard_domain:
4153

4254
``DASHBOARD_DOMAIN``
@@ -1082,6 +1094,14 @@ X509 Certificates
10821094
Misc Services
10831095
-------------
10841096

1097+
``IMAGE_OWNER``
1098+
~~~~~~~~~~~~~~~
1099+
1100+
- **Explanation:** Docker registry namespace for OpenWISP images. Change
1101+
this only if you are using custom-built images or a private registry.
1102+
- **Valid Values:** A valid Docker registry namespace.
1103+
- **Default:** ``openwisp``
1104+
10851105
``REDIS_HOST``
10861106
~~~~~~~~~~~~~~
10871107

images/common/init_command.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ elif [ "$MODULE_NAME" = 'nginx' ]; then
5757
if [ "$NGINX_CUSTOM_FILE" = 'True' ]; then
5858
nginx -g 'daemon off;'
5959
fi
60+
# Expand escape sequences in the optional events block so it can be injected
61+
# correctly into the nginx configuration template.
62+
NGINX_EVENTS_BLOCK=$(printf "%b" "${NGINX_EVENTS_BLOCK:-}")
63+
export NGINX_EVENTS_BLOCK
64+
# Use a sentinel value when the variable is unset. Since envsubst cannot
65+
# conditionally omit directives, we later remove any line containing this
66+
# sentinel from the generated nginx.conf.
67+
export NGINX_WORKER_RLIMIT_NOFILE="${NGINX_WORKER_RLIMIT_NOFILE:-__UNSET__}"
6068
envsubst </etc/nginx/nginx.template.conf >/etc/nginx/nginx.conf
69+
# Remove incomplete worker_rlimit_nofile directives if env var is unset or empty
70+
sed -i '/__UNSET__/d; /^worker_rlimit_nofile *$/d; /^[[:space:]]*$/d' /etc/nginx/nginx.conf
6171
envsubst_create_config /etc/nginx/openwisp.internal.template.conf internal INTERNAL
6272
if [ "$SSL_CERT_MODE" = 'Yes' ]; then
6373
nginx_prod

images/common/services.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99

1010
def database_status():
11+
import psycopg
12+
1113
try:
12-
psycopg2.connect(
14+
with psycopg.connect(
1315
dbname=os.environ["DB_NAME"],
1416
user=os.environ["DB_USER"],
1517
password=os.environ["DB_PASS"],
@@ -19,8 +21,9 @@ def database_status():
1921
sslcert=os.environ["DB_SSLCERT"],
2022
sslkey=os.environ["DB_SSLKEY"],
2123
sslrootcert=os.environ["DB_SSLROOTCERT"],
22-
)
23-
except psycopg2.OperationalError:
24+
):
25+
pass
26+
except psycopg.OperationalError:
2427
time.sleep(3)
2528
return False
2629
else:
@@ -74,8 +77,6 @@ def redis_status():
7477
arguments = sys.argv[1:]
7578
# Database Connection
7679
if "database" in arguments:
77-
import psycopg2
78-
7980
print("Waiting for database to become available...")
8081
connected = False
8182
while not connected:

0 commit comments

Comments
 (0)