Skip to content

Commit 41938ec

Browse files
aequitasmxsasha
authored andcommitted
Use bundled compose instead of system one to reduce issues with different versions of compose
- simplify deployment instructions by removing version pins as those where for Docker versions more than a year old
1 parent 393cbe5 commit 41938ec

File tree

9 files changed

+81
-115
lines changed

9 files changed

+81
-115
lines changed

.github/workflows/docker.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ env:
1919
# should be used to transfer images between jobs. Forked and dependabot builds don't
2020
# have permission to push to registry.
2121
use_registry: ${{ ! (github.event_name == 'pull_request' && (github.event.pull_request.head.repo.full_name != github.repository || startsWith(github.head_ref, 'dependabot/'))) }}
22+
COMPOSE_VERSION: 2.40.3
2223

2324
jobs:
2425
# builds all docker images in parallel
2526
build-docker:
26-
runs-on: ubuntu-22.04
27+
runs-on: ubuntu-24.04
2728

2829
strategy:
2930
matrix:
@@ -227,7 +228,7 @@ jobs:
227228
retention-days: 1
228229

229230
docs:
230-
runs-on: ubuntu-22.04
231+
runs-on: ubuntu-24.04
231232
needs: [build-docker]
232233
steps:
233234
- name: Branch deployment docs
@@ -272,7 +273,7 @@ jobs:
272273
sudo apt-get update
273274
274275
# upgrade Docker
275-
sudo apt install --upgrade docker-ce docker-compose-plugin=2.33.0\*
276+
sudo apt install --upgrade docker-ce docker-compose-plugin=$COMPOSE_VERSION\*
276277
277278
- name: Debug info
278279
run: |
@@ -374,7 +375,7 @@ jobs:
374375
lintcheck:
375376
name: lint/check
376377
needs: [build-docker]
377-
runs-on: ubuntu-22.04
378+
runs-on: ubuntu-24.04
378379

379380
env:
380381
# used in `compose.yaml` files to determine version of images to pull
@@ -452,7 +453,7 @@ jobs:
452453
sudo apt-get update
453454
454455
# upgrade Docker
455-
sudo apt install --upgrade docker-ce docker-compose-plugin=2.33.0\*
456+
sudo apt install --upgrade docker-ce docker-compose-plugin=$COMPOSE_VERSION\*
456457
457458
- name: Debug info
458459
run: |
@@ -539,7 +540,7 @@ jobs:
539540
sudo apt-get update
540541
541542
# upgrade Docker
542-
sudo apt install --upgrade docker-ce docker-compose-plugin=2.33.0\*
543+
sudo apt install --upgrade docker-ce docker-compose-plugin=$COMPOSE_VERSION\*
543544
544545
- name: Debug info
545546
run: |
@@ -657,7 +658,7 @@ jobs:
657658
sudo apt-get update
658659
659660
# upgrade Docker
660-
sudo apt install --upgrade docker-ce docker-compose-plugin=2.33.0\*
661+
sudo apt install --upgrade docker-ce docker-compose-plugin=$COMPOSE_VERSION\*
661662
662663
- name: Debug info
663664
run: |

docker/compose-dist.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
3+
# wrapper to run the right compose command with the right environment variables from the util container
4+
5+
set -e
6+
7+
# determine install base for multi environment deployments (parent of directory containing this file)
8+
INTERNETNL_INSTALL_BASE=$(dirname "$(dirname "$(readlink -f "$0")")")
9+
10+
exec docker run -ti --rm --pull=never \
11+
--volume /var/run/docker.sock:/var/run/docker.sock \
12+
--volume "$INTERNETNL_INSTALL_BASE:/opt/Internet.nl" \
13+
--workdir /opt/Internet.nl \
14+
--network none \
15+
"ghcr.io/internetstandards/util:$RELEASE" \
16+
docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env "$@"

docker/deploy.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ echo "Deploying release: $RELEASE"
88

99
# copy release specific support files
1010
cp -v /dist/docker/* docker
11+
# put $RELEASE into the compose.sh file
12+
envsubst '$RELEASE' < docker/compose-dist.sh > docker/compose.sh
13+
chmod a+x docker/compose.sh
1114

1215
# set release version in local.env config
1316
echo "RELEASE='$RELEASE' # deploy $(date)" >> docker/local.env

docker/util.Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
FROM alpine:3.20.3
1+
FROM alpine:3.22
22

3-
RUN apk add --no-cache curl postgresql15 python3 py3-prometheus-client py3-requests jq docker-cli docker-cli-compose pigz jq
3+
RUN apk add --no-cache curl postgresql15 python3 py3-prometheus-client py3-requests jq docker-cli docker-cli-compose pigz jq envsubst
44

55
# install cron tasks
66
COPY docker/cron/periodic /etc/periodic/
@@ -25,6 +25,7 @@ COPY docker/host-dist.env /dist/docker/
2525
COPY docker/host-multi-dist.env /dist/docker/
2626
COPY docker/compose.yaml /dist/docker/
2727
COPY docker/user_manage.sh /dist/docker/
28+
COPY docker/compose-dist.sh /dist/docker/
2829
RUN chmod a-w /dist/docker/*
2930

3031
# add release as label for auto_update feature

documentation/Docker-DNS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ Letsencrypt account ID and private key are stored in a Docker volume for persist
114114

115115
When deploying a new instance, first complete the full setup. After that perform the following steps to restore the account:
116116

117-
docker compose --project-name=internetnl-prod stop webserver
117+
/opt/Internet.nl/docker/compose.sh stop webserver
118118
rm -rf /var/lib/docker/volumes/internetnl-prod_certbot-config/_data/*
119119
cp -r <location of backed up _data directory> /var/lib/docker/volumes/internetnl-prod_certbot-config/_data/
120-
docker compose --project-name=internetnl-prod start webserver
120+
/opt/Internet.nl/docker/compose.sh start webserver
121121

122122
The certbot instance in the webserver container should start requesting a certificate for the domain after at most 1 minute. You can check the progress using:
123123

124-
docker compose --project-name=internetnl-prod exec webserver cat /var/log/letsencrypt/letsencrypt.log
124+
/opt/Internet.nl/docker/compose.sh exec webserver cat /var/log/letsencrypt/letsencrypt.log

documentation/Docker-deployment-batch.md

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,21 @@ A domain name is recommended to access the server and have Letsencrypt TLS be se
3535

3636
After installation and basic configuration of the OS switch to `root` user.
3737

38-
Run the following command to install required dependencies:
39-
40-
apt update
41-
apt install -yqq ca-certificates curl gnupg
42-
43-
Setup Docker Apt repository:
44-
45-
install -m 0755 -d /etc/apt/keyrings
46-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
47-
chmod a+r /etc/apt/keyrings/docker.gpg
48-
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
49-
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" > /etc/apt/sources.list.d/docker.list
50-
apt update
51-
52-
Install Docker:
53-
54-
apt install -yqq docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
55-
56-
Configure Docker for IPv6 and Live restore:
57-
58-
echo '{"experimental": true, "ip6tables": true, "live-restore": true}' > /etc/docker/daemon.json
59-
systemctl stop docker
60-
systemctl start docker
38+
Run the following commands to configure Docker for IPv6 and Live restore and to install required dependencies, setup Docker Apt repository, and install Docker:
39+
40+
mkdir -p /etc/docker && \
41+
echo '{"ip6tables": true, "live-restore": true}' > /etc/docker/daemon.json && \
42+
apt update && \
43+
apt install -yqq --no-install-recommends --no-install-suggests ca-certificates curl jq gnupg && \
44+
install -m 0755 -d /etc/apt/keyrings && \
45+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o - > /etc/apt/keyrings/docker.gpg && \
46+
chmod a+r /etc/apt/keyrings/docker.gpg && \
47+
echo -e "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] \
48+
https://download.docker.com/linux/"$(. /etc/os-release && echo "$ID $VERSION_CODENAME")" stable\n \
49+
deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] \
50+
https://download.docker.com/linux/"$(. /etc/os-release && echo "$ID $VERSION_CODENAME")" test" \
51+
> /etc/apt/sources.list.d/docker.list && apt update && \
52+
apt install -yqq --no-install-recommends --no-install-suggests docker-ce
6153

6254
## Application setup
6355

@@ -127,7 +119,7 @@ This command should complete without an error, indicating the application stack
127119

128120
Create database indexes:
129121

130-
docker compose --project-name=internetnl-prod exec app ./manage.py api_create_db_indexes
122+
/opt/Internet.nl/docker/compose.sh exec app ./manage.py api_create_db_indexes
131123

132124
## DNS setup
133125

@@ -169,9 +161,9 @@ Please see the generic troubleshooting documentation in [Deployment#Troubleshoot
169161
If batch jobs seem to be stuck, check the `Batch` dashboard in Grafana (see [Deployment#Grafana](Docker-deployment.md#metrics-grafanaprometheus)). The `Individual task completion rate` graph should show a variaty of tasks being completed per second. If this graph is empty or shows gaps this might indicate the batch jobs got stuck in a deadlock. In this case bring down the environment, remove the Redis and RabbitMQ volumes and start the environment again:
170162

171163
cd /opt/Internet.nl
172-
docker compose --project-name=internetnl-prod down
164+
/opt/Internet.nl/docker/compose.sh down
173165
docker volume rm internetnl-prod_rabbitmq
174166
docker volume rm internetnl-prod_redis
175-
env -i docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env up --wait --no-build
167+
env -i /opt/Internet.nl/docker/compose.sh up --wait --no-build
176168

177169
This issue can happen on rare occasions, is you encounter this persistently please create an issue in the Internet.nl repository: https://github.com/internetstandards/Internet.nl/issues/new

documentation/Docker-deployment.md

Lines changed: 24 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -38,68 +38,21 @@ A public domain name or subdomain is required. It should be possible to set the
3838

3939
After installation and basic configuration of the OS switch to `root` user.
4040

41-
Currently some Docker and Compose versions cause issues during setup (see: `documentation/Docker-getting-started.md#Prerequisites`). The following command will install a file that will prevent installing unsupported versions:
42-
43-
cat > /etc/apt/preferences.d/internetnl-docker-supported-versions <<EOF
44-
# prevent installation of unsupported versions of Docker/Compose
45-
# https://github.com/internetstandards/Internet.nl/pull/1419
46-
Package: docker-ce
47-
Pin: version 5:25.*
48-
Pin-priority: -1
49-
50-
Package: docker-ce
51-
Pin: version 5:26.0.*
52-
Pin-priority: -1
53-
54-
Package: docker-ce
55-
Pin: version 5:26.1.0-*
56-
Pin-priority: -1
57-
58-
Package: docker-ce
59-
Pin: version 5:26.1.1-*
60-
Pin-priority: -1
61-
62-
Package: docker-ce
63-
Pin: version 5:26.1.2-*
64-
Pin-priority: -1
65-
66-
Package: docker-compose-plugin
67-
Pin: version 2.24.*
68-
Pin-priority: -1
69-
70-
Package: docker-compose-plugin
71-
Pin: version 2.25.*
72-
Pin-priority: -1
73-
74-
Package: docker-compose-plugin
75-
Pin: version 2.26.*
76-
Pin-priority: -1
77-
78-
Package: docker-compose-plugin
79-
Pin: version 2.27.1-*
80-
Pin-priority: -1
81-
EOF
82-
83-
Run the following command to install required dependencies, setup Docker Apt repository, and install Docker:
84-
41+
Run the following commands to configure Docker for IPv6 and Live restore and to install required dependencies, setup Docker Apt repository, and install Docker:
8542

43+
mkdir -p /etc/docker && \
44+
echo '{"ip6tables": true, "live-restore": true}' > /etc/docker/daemon.json && \
8645
apt update && \
87-
apt install -yqq ca-certificates curl jq gnupg && \
46+
apt install -yqq --no-install-recommends --no-install-suggests ca-certificates curl jq gnupg && \
8847
install -m 0755 -d /etc/apt/keyrings && \
89-
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
48+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o - > /etc/apt/keyrings/docker.gpg && \
9049
chmod a+r /etc/apt/keyrings/docker.gpg && \
9150
echo -e "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] \
9251
https://download.docker.com/linux/"$(. /etc/os-release && echo "$ID $VERSION_CODENAME")" stable\n \
9352
deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] \
9453
https://download.docker.com/linux/"$(. /etc/os-release && echo "$ID $VERSION_CODENAME")" test" \
9554
> /etc/apt/sources.list.d/docker.list && apt update && \
96-
apt install -yqq docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
97-
98-
Configure Docker for IPv6 and Live restore:
99-
100-
echo '{"experimental": true, "ip6tables": true, "live-restore": true}' > /etc/docker/daemon.json && \
101-
systemctl stop docker && \
102-
systemctl start docker
55+
apt install -yqq --no-install-recommends --no-install-suggests docker-ce
10356

10457
## Application setup
10558

@@ -177,15 +130,19 @@ After deployment is complete, all services are healthy and DNS is setup you can
177130

178131
For more information see: [documentation/Docker-live-tests.md](Docker-live-tests.md)
179132

133+
## Compose command
134+
135+
To reduce issues with different versions a Compose command is included in the installation and can be accessed using `/opt/Internet.nl/docker/compose.sh`. Use this command for everything where you would normaly use `docker compose` to manage the Compose project.
136+
180137
## Logging
181138

182139
Log output from containers/services can be obtained using the following command:
183140

184-
docker compose --project-name=internetnl-prod logs -f
141+
/opt/Internet.nl/docker/compose.sh logs -f
185142

186143
Or only for specific services:
187144

188-
docker compose --project-name=internetnl-prod logs -f app
145+
/opt/Internet.nl/docker/compose.sh logs -f app
189146

190147
These same logs are also sent to the `journald` daemon to be logged by the OS. This can then be used to forward to remote logging, etc.
191148

@@ -205,11 +162,11 @@ By default task start and completion is not logged. To enable this set the `CELE
205162

206163
When things don't seem to be working as expected and the logs don't give clear indications of the cause the first thing to do is check the status of the running containers/services:
207164

208-
docker compose --project-name=internetnl-prod ps -a
165+
/opt/Internet.nl/docker/compose.sh ps -a
209166

210167
Or use this command to omit the `COMMAND` and `PORTS` columns for a more compact view with only relevant information:
211168

212-
docker compose --project-name=internetnl-prod ps -a --format "table {{.Name}}\t{{.Image}}\t{{.Service}}\t{{.RunningFor}}\t{{.Status}}"
169+
/opt/Internet.nl/docker/compose.sh ps -a --format "table {{.Name}}\t{{.Image}}\t{{.Service}}\t{{.RunningFor}}\t{{.Status}}"
213170

214171
Containers/services should have a `STATUS` of `Up` and there should be no containers/services with `unhealthy`. The `db-migrate` having status `Exited (0)` is expected. Containers/services with a short uptime (seconds/minutes) might indicate it restarted recently due to an error.
215172

@@ -219,12 +176,12 @@ If a container/service is not up and healthy the cause might be deduced by inspe
219176

220177
It might be possible not all containers that should be running are running. To have Docker Compose check the running instance and bring up any missing components run:
221178

222-
env -i docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env up --wait --no-build
179+
env -i /opt/Internet.nl/docker/compose.sh up --wait --no-build
223180

224181
If this does not solve the issue you might want to reset the instance by bringing everything down and up again:
225182

226-
docker compose --project-name=internetnl-prod down
227-
env -i docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env up --wait --no-build
183+
/opt/Internet.nl/docker/compose.sh down
184+
env -i /opt/Internet.nl/docker/compose.sh up --wait --no-build
228185

229186
If this does not work problems might lay deeper and OS level troubleshooting might be required.
230187

@@ -242,7 +199,7 @@ Docker Compose relies on an internal DNS resolver to resolve container/services
242199

243200
The issue can be resolved by restarting the application:
244201

245-
docker compose --project-name=internetnl-prod restart
202+
/opt/Internet.nl/docker/compose.sh restart
246203

247204
## Updating
248205

@@ -280,11 +237,11 @@ This variable can be set to either of these values:
280237

281238
Auto upgrades are performed by the `cron-docker` container/service. Progress/errors can be viewed by inspecting the container's logs:
282239

283-
docker compose --project-name=internetnl-prod logs --follow cron-docker
240+
/opt/Internet.nl/docker/compose.sh logs --follow cron-docker
284241

285242
To manually kick off the update process use the following command:
286243

287-
docker compose --project-name=internetnl-prod exec cron-docker /etc/periodic-docker/15min/auto_update
244+
/opt/Internet.nl/docker/compose.sh exec cron-docker /etc/periodic-docker/5min/auto_update
288245

289246
**notice**: the update logging might be cut-off at the end because the `cron-docker` container/service will be restarted in the process.
290247

@@ -313,11 +270,11 @@ In essence downgrading is the same procedure as upgrading. For example, to roll
313270

314271
By default the installation will try to request a HTTPS certificate with Letsencrypt for the domain and it's subdomains. If this is not possible it will fall back to a self-signed 'localhost' certificate. If requesting a certificate fails you can debug it by viewing the logs using:
315272

316-
docker compose --project-name=internetnl-prod logs webserver
273+
/opt/Internet.nl/docker/compose.sh logs webserver
317274

318275
and
319276

320-
docker compose --project-name=internetnl-prod exec webserver cat /var/log/letsencrypt/letsencrypt.log
277+
/opt/Internet.nl/docker/compose.sh exec webserver cat /var/log/letsencrypt/letsencrypt.log
321278

322279
It may take a few minutes after starting for the Letsencrypt certificates to be registered and loaded.
323280

@@ -405,7 +362,7 @@ Current alert status can seen at: https://example.com/prometheus/alerts or https
405362

406363
If notification emails are not being sent even though alert status shows red see Alertmanager logging for debugging:
407364

408-
docker compose --project-name=internetnl-prod logs --follow alertmanager
365+
/opt/Internet.nl/docker/compose.sh logs --follow alertmanager
409366

410367
## Restricting access
411368

@@ -437,7 +394,7 @@ When adding both users and IPs in `ALLOW_LIST`, users connecting from an IP in t
437394

438395
After changing the IP or hostname in the `docker/host.env` file run:
439396

440-
env -i docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env up --wait --no-build
397+
env -i /opt/Internet.nl/docker/compose.sh up --wait --no-build
441398

442399
to update the DNSSEC accordingly.
443400

documentation/Docker-getting-started.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ This documented is intended as a quick simple guide to setup a development envir
44

55
## Prerequisites
66

7-
An OCI compatible container runtime with [Compose V2](https://docs.docker.com/compose/migrate/) is required to run the project. For example one of the following:
7+
An OCI compatible container runtime (Docker) with a recent [Compose](https://github.com/docker/compose) is required to run the project. For example one of the following:
88

99
- [Docker](https://docs.docker.com/get-docker/) for Linux, (supported)
1010
- [Colima](https://github.com/abiosoft/colima) for Mac (recommended)
11-
- [OrbStack](https://orbstack.dev/download) for Mac (non open source, free, tested version 1.10.2)
11+
- [OrbStack](https://orbstack.dev/download) for Mac (non open source, free, tested version 2.0.5)
1212
- [Docker](https://docs.docker.com/get-docker/) for Mac (supported)
1313
- [Docker](https://docs.docker.com/get-docker/) for Windows (untested)
1414

15-
**notice**: some versions of Docker Engine might experience issues with internal DNS resolving and will cause tests to fail. Versions from and including `25.0.5` to and including `26.1.2` should be avoided.
16-
17-
**notice**: Docker Compose Plugin versions below and up to `2.27.2` should be avoided due to missing features.
18-
1915
**notice**: your Docker runtime should be configured with enough memory and CPU, otherwise the environment will be unstable. Minimum is at least 4GB memory and 2 CPU cores, more is better for quicker rebuild/restart of images/containers.
2016

2117
**for arm users (eg apple m1)**: nassl will not compile on x64 architectures, so use the option to start your container engine in x86 mode. For colima this can be done with `colima start --arch x86_64`. As per the system requirements noted above, the right way to start with colima would then be: `colima start --arch x86_64 --cpu 2 --memory 4`, but giving it some room would make that: `colima start --arch x86_64 --cpu 4 --memory 8`.

0 commit comments

Comments
 (0)