Skip to content

Commit

Permalink
WIP: deployment via docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
aequitas committed Oct 9, 2024
1 parent 9aa7532 commit 8548822
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 18 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,18 +220,12 @@ jobs:
To deploy this specific build to a existing deployment run the following update commands:
cd /opt/Internet.nl/ && \\
RELEASE="${{ github.event.pull_request.head.sha }}" >> docker/local.env && \\
DOCKER_REGISTRY="${{env.DOCKER_REGISTRY}}" >> docker/local.env && \\
curl -sSfO --output-dir docker https://raw.githubusercontent.com/${{github.repository}}/\${{ github.event.pull_request.head.sha }}/docker/defaults.env && \\
curl -sSfO --output-dir docker https://raw.githubusercontent.com/${{github.repository}}/\${{ github.event.pull_request.head.sha }}/docker/docker-compose.yml && \\
curl -sSfO https://raw.githubusercontent.com/${{github.repository}}/\${{ github.event.pull_request.head.sha }}/docker/user_manage.sh && \\
chmod 755 user_manage.sh && \\
docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env pull && \\
# temporary solution to recreate containers when configs change: https://github.com/internetstandards/Internet.nl/issues/1490 \\
docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env rm --stop --force cron-docker prometheus alertmanager nginx_logs_exporter && \\
docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env up --remove-orphans --wait --no-build
docker run -ti --rm \\
--volume /var/run/docker.sock:/var/run/docker.sock \\
--volume /opt/Internet.nl:/opt/Internet.nl \\
--network none \\
ghcr.io/internetstandards/cron:${{ needs.build-docker.outputs.internetnl_version }} \\
/deploy.sh
EOF
- name: Release deployment docs
Expand All @@ -243,7 +237,6 @@ jobs:
cd /opt/Internet.nl/ && \\
RELEASE="${{ needs.build-docker.outputs.internetnl_version }}" >> docker/local.env && \\
DOCKER_REGISTRY="${{env.DOCKER_REGISTRY}}" >> docker/local.env && \\
curl -sSfO --output-dir docker https://raw.githubusercontent.com/${{github.repository}}/\${{ needs.build-docker.outputs.internetnl_version }}/docker/defaults.env && \\
curl -sSfO --output-dir docker https://raw.githubusercontent.com/${{github.repository}}/\${{ needs.build-docker.outputs.internetnl_version }}/docker/docker-compose.yml && \\
curl -sSfO https://raw.githubusercontent.com/${{github.repository}}/\${{ needs.build-docker.outputs.internetnl_version }}/docker/user_manage.sh && \\
Expand Down
16 changes: 13 additions & 3 deletions docker/cron.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
FROM alpine:3.18
FROM alpine:3.20

RUN apk add --no-cache curl postgresql15 python3 py3-prometheus-client py3-requests jq docker-cli docker-cli-compose
RUN apk add --no-cache curl postgresql15 python3 py3-prometheus-client py3-requests jq docker-cli docker-cli-compose

COPY docker/cron/periodic /etc/periodic/
COPY docker/cron/update.sh /update.sh

COPY docker/cron/deploy.sh /deploy.sh

RUN mkdir -p /dist/docker
COPY docker/defaults.env /dist/docker/defaults.env
COPY docker/docker-compose.yml /dist/docker/docker-compose.yml
COPY docker/user_manage.sh /dist/docker/user_manage.sh

ARG RELEASE
ENV RELEASE=$RELEASE

# run crond in foreground and log output of crons
CMD crond -f -l2
CMD crond -f -l2
21 changes: 21 additions & 0 deletions docker/cron/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env sh

set -e

cd /opt/Internet.nl/

echo "Deploying release: $RELEASE"

# copy release specific support files
cp -v /dist/docker/* docker

# set release version in local.env config
echo "RELEASE='$RELEASE' # deploy ${date}" >> docker/local.env

# download release images
docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env pull

# bring up application with new release
docker compose --env-file=docker/defaults.env --env-file=docker/host.env --env-file=docker/local.env up --remove-orphans --wait --no-build

echo "Deploy completed"
5 changes: 3 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -745,14 +745,15 @@ services:

profiles:
- cron

update:
image: ${DOCKER_IMAGE_CRON:-ghcr.io/internetstandards/cron:${INTERNETNL_VERSION}}
image: ${DOCKER_IMAGE_CRON:-ghcr.io/internetstandards/cron:${RELEASE}}
build:
context: ..
dockerfile: docker/cron.Dockerfile
environment:
- AUTO_UPDATE_BRANCH
- INTERNETNL_VERSION
- RELEASE
command: /update.sh
# this container runs to completion and exits with 0
restart: on-failure
Expand Down

0 comments on commit 8548822

Please sign in to comment.