Skip to content

Commit 01c0f0c

Browse files
committed
docker/ci: fix acme/dkim persistence and zone deploy
1 parent 8e49877 commit 01c0f0c

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

.github/workflows/docker-ci.yaml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ jobs:
124124
echo "${{ secrets.STAGING_SSH_KEY }}" >> ~/.ssh/id_ed25519
125125
chmod 600 ~/.ssh/id_ed25519
126126
ssh-keyscan ${HOST} > ~/.ssh/known_hosts
127-
# save previous acme & dkim state
128-
rsync -avz root@${HOST}:/var/lib/acme ${ACME_DIR} || true
129-
rsync -avz root@${HOST}:/etc/dkimkeys ${DKIM_DIR} || true
127+
# save previous acme & dkim state (Docker bind-mount paths)
128+
rsync -avz root@${HOST}:/srv/chatmail/certs/ ${ACME_DIR}/ || true
129+
rsync -avz root@${HOST}:/srv/chatmail/dkim/ ${DKIM_DIR}/ || true
130130
# store previous acme & dkim state on ns.testrun.org, if it contains useful certs
131131
if [ -f ${DKIM_DIR}/opendkim.private ]; then rsync -avz -e "ssh -o StrictHostKeyChecking=accept-new" ${DKIM_DIR} root@ns.testrun.org:/tmp/ || true; fi
132132
if [ "$(ls -A ${ACME_DIR}/certs 2>/dev/null)" ]; then rsync -avz -e "ssh -o StrictHostKeyChecking=accept-new" ${ACME_DIR} root@ns.testrun.org:/tmp/ || true; fi
@@ -197,20 +197,10 @@ jobs:
197197
run: |
198198
GHCR_IMAGE="${{ needs.build.outputs.image }}"
199199
rsync -avz --exclude='.git' --exclude='venv' --exclude='__pycache__' ./ root@${HOST}:/srv/chatmail/relay/
200-
# Override: bind-mount data dirs + custom chatmail.ini + pre-built image
201-
ssh root@${HOST} "cat > /srv/chatmail/relay/docker-compose.override.yaml << EOF
202-
services:
203-
chatmail:
204-
image: ${GHCR_IMAGE}
205-
volumes:
206-
- /srv/chatmail/dkim:/etc/dkimkeys
207-
- /srv/chatmail/certs:/var/lib/acme
208-
- /srv/chatmail/chatmail.ini:/etc/chatmail/chatmail.ini
209-
EOF"
210200
# Login to GHCR on VPS and pull pre-built image
211201
echo "${{ secrets.GITHUB_TOKEN }}" | ssh root@${HOST} 'docker login ghcr.io -u ${{ github.actor }} --password-stdin'
212202
ssh root@${HOST} "docker pull ${GHCR_IMAGE}"
213-
ssh root@${HOST} "cd /srv/chatmail/relay && MAIL_DOMAIN=${HOST} docker compose up -d"
203+
ssh root@${HOST} "cd /srv/chatmail/relay && CHATMAIL_IMAGE=${GHCR_IMAGE} MAIL_DOMAIN=${HOST} docker compose -f docker-compose.yaml -f docker/docker-compose.ci.yaml up -d"
214204
215205
- name: wait for container to become healthy
216206
env:
@@ -241,10 +231,10 @@ jobs:
241231
HOST: ${{ matrix.host }}
242232
ZONE: ${{ matrix.zone_file }}
243233
run: |
244-
ssh root@${HOST} chown opendkim:opendkim -R /srv/chatmail/dkim
234+
ssh root@${HOST} 'docker exec chatmail chown opendkim:opendkim -R /etc/dkimkeys'
245235
# run cmdeploy dns inside the container
246-
ssh root@${HOST} 'docker exec chatmail cmdeploy dns --ssh-host @local --zonefile /tmp/staging.zone --verbose'
247-
ssh root@${HOST} 'docker cp chatmail:/tmp/staging.zone /tmp/staging.zone'
236+
ssh root@${HOST} 'docker exec chatmail cmdeploy dns --ssh-host @local --zonefile /opt/chatmail/staging.zone --verbose'
237+
ssh root@${HOST} 'docker cp chatmail:/opt/chatmail/staging.zone /tmp/staging.zone'
248238
scp root@${HOST}:/tmp/staging.zone staging-generated.zone
249239
cat staging-generated.zone >> .github/workflows/${ZONE}
250240
cat .github/workflows/${ZONE}

docker/docker-compose.ci.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Used by .github/workflows/docker-ci.yaml
2+
# The GHCR image is set via CHATMAIL_IMAGE env var at deploy time.
3+
services:
4+
chatmail:
5+
image: ${CHATMAIL_IMAGE:-chatmail-relay:latest}
6+
volumes:
7+
- /srv/chatmail/dkim:/etc/dkimkeys
8+
- /srv/chatmail/certs:/var/lib/acme

0 commit comments

Comments
 (0)