Skip to content

Commit 214c1d5

Browse files
committed
ci: extend for debian 12/13
- docker-ci with matrix - dockerfile with variable
1 parent 690a8c0 commit 214c1d5

2 files changed

Lines changed: 54 additions & 28 deletions

File tree

.github/workflows/docker-ci.yaml

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# 2. repository_dispatch from chatmail/relay -- builds the dispatched relay ref
66
# 3. workflow_dispatch -- manual build of any relay branch/tag
77
#
8-
# Tags: sha-<relay-7char>, branch name, semver (on release tags)
8+
# Tags: sha-<relay-7char>[distro_suffix], branch name[distro_suffix], semver release tags (Bookworm only)
99
# PRs: build only, no push
1010

1111
name: Build and push chatmail-relay image
@@ -46,10 +46,18 @@ env:
4646

4747
jobs:
4848
build:
49-
name: Build Docker image
49+
name: Build Docker image (debian ${{ matrix.debian_version }})
5050
runs-on: ubuntu-latest
51+
strategy:
52+
fail-fast: false
53+
matrix:
54+
include:
55+
- debian_version: 12
56+
distro_suffix: ""
57+
- debian_version: 13
58+
distro_suffix: "-trixie"
5159
outputs:
52-
image_tag: ${{ steps.meta.outputs.tag }}
60+
relay_sha_short: ${{ steps.meta.outputs.relay_sha_short }}
5361
relay_ref: ${{ steps.meta.outputs.relay_ref }}
5462
permissions:
5563
contents: read
@@ -98,6 +106,7 @@ jobs:
98106
RELAY_REF_INPUT: ${{ steps.relay.outputs.ref }}
99107
EVENT_NAME: ${{ github.event_name }}
100108
REF_NAME: ${{ github.ref_name }}
109+
DISTRO_SUFFIX: ${{ matrix.distro_suffix }}
101110
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102111
run: |
103112
IMAGE="${REGISTRY}/${IMAGE_NAME}"
@@ -113,38 +122,40 @@ jobs:
113122
echo "relay_sha_short=${RELAY_SHA_SHORT}" >> "$GITHUB_OUTPUT"
114123
echo "relay_ref=${RELAY_REF}" >> "$GITHUB_OUTPUT"
115124
echo "build_date=${BUILD_DATE}" >> "$GITHUB_OUTPUT"
116-
echo "tag=sha-${RELAY_SHA_SHORT}" >> "$GITHUB_OUTPUT"
125+
echo "tag=sha-${RELAY_SHA_SHORT}${DISTRO_SUFFIX}" >> "$GITHUB_OUTPUT"
117126
118127
# -- Tags --
119-
# Always: relay SHA tag
120-
TAGS="${IMAGE}:sha-${RELAY_SHA_SHORT}"
128+
# Always: relay SHA tag (with distro suffix)
129+
TAGS="${IMAGE}:sha-${RELAY_SHA_SHORT}${DISTRO_SUFFIX}"
121130
if [ "$EVENT_NAME" = "push" ] || \
122131
[ "$EVENT_NAME" = "pull_request" ]; then
123132
# Docker-repo push/PR: add docker branch tag (sanitize slashes)
124133
BRANCH_TAG=$(echo "${REF_NAME}" | sed 's|/|-|g')
125-
TAGS="${TAGS}"$'\n'"${IMAGE}:${BRANCH_TAG}"
134+
TAGS="${TAGS}"$'\n'"${IMAGE}:${BRANCH_TAG}${DISTRO_SUFFIX}"
126135
else
127136
# Dispatch: tags based on relay ref
128137
BRANCH_TAG=$(echo "${RELAY_REF}" | sed 's|/|-|g')
129-
TAGS="${TAGS}"$'\n'"${IMAGE}:${BRANCH_TAG}"
138+
TAGS="${TAGS}"$'\n'"${IMAGE}:${BRANCH_TAG}${DISTRO_SUFFIX}"
130139
if [[ "${RELAY_REF}" =~ ^v?([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
131140
MAJOR="${BASH_REMATCH[1]}"
132141
MINOR="${BASH_REMATCH[2]}"
133142
PATCH="${BASH_REMATCH[3]}"
134143
VERSION="${MAJOR}.${MINOR}.${PATCH}"
135-
TAGS="${TAGS}"$'\n'"${IMAGE}:${VERSION}"$'\n'"${IMAGE}:${MAJOR}.${MINOR}"
136-
# `latest` only if this is the highest semver published so far,
144+
TAGS="${TAGS}"$'\n'"${IMAGE}:${VERSION}${DISTRO_SUFFIX}"$'\n'"${IMAGE}:${MAJOR}.${MINOR}${DISTRO_SUFFIX}"
145+
# `latest` only for Bookworm and only if this is the highest semver published so far,
137146
# so a back-ported patch on an old minor line cannot clobber it.
138-
HIGHEST=$(gh api \
139-
"orgs/chatmail/packages/container/docker/versions?per_page=100" \
140-
--jq '[.[].metadata.container.tags[]
141-
| select(test("^[0-9]+\\.[0-9]+\\.[0-9]+$"))]
142-
| sort_by(split(".") | map(tonumber)) | last // empty' \
143-
2>/dev/null) || true
144-
if [ -z "$HIGHEST" ] || \
145-
[ "$(printf '%s\n%s\n' "$HIGHEST" "$VERSION" \
146-
| sort -V | tail -1)" = "$VERSION" ]; then
147-
TAGS="${TAGS}"$'\n'"${IMAGE}:latest"
147+
if [ -z "${DISTRO_SUFFIX}" ]; then
148+
HIGHEST=$(gh api \
149+
"orgs/chatmail/packages/container/docker/versions?per_page=100" \
150+
--jq '[.[].metadata.container.tags[]
151+
| select(test("^[0-9]+\\.[0-9]+\\.[0-9]+$"))]
152+
| sort_by(split(".") | map(tonumber)) | last // empty' \
153+
2>/dev/null) || true
154+
if [ -z "$HIGHEST" ] || \
155+
[ "$(printf '%s\n%s\n' "$HIGHEST" "$VERSION" \
156+
| sort -V | tail -1)" = "$VERSION" ]; then
157+
TAGS="${TAGS}"$'\n'"${IMAGE}:latest"
158+
fi
148159
fi
149160
fi
150161
fi
@@ -216,9 +227,10 @@ jobs:
216227
GIT_HASH=${{ steps.meta.outputs.relay_sha }}
217228
SOURCE_REF=${{ steps.meta.outputs.relay_ref }}
218229
BUILD_DATE=${{ steps.meta.outputs.build_date }}
230+
DEBIAN_VERSION=${{ matrix.debian_version }}
219231
220-
test:
221-
name: Integration test
232+
test_bookworm:
233+
name: Integration test (bookworm)
222234
needs: build
223235
permissions: {}
224236
# TODO: revert to @main once cmlxc docker support is merged
@@ -228,5 +240,19 @@ jobs:
228240
cmlxc_version: j4n/docker-support
229241
cmlxc_commands: |
230242
cmlxc init
231-
cmlxc docker deploy dock0 --source ghcr:${{ needs.build.outputs.image_tag }}
243+
cmlxc docker deploy dock0 --source ghcr:sha-${{ needs.build.outputs.relay_sha_short }}
244+
RELAY_REF=${{ needs.build.outputs.relay_ref }} cmlxc test-cmdeploy dock0
245+
246+
test_trixie:
247+
name: Integration test (trixie)
248+
needs: build
249+
permissions: {}
250+
# TODO: revert to @main once cmlxc docker support is merged
251+
uses: chatmail/cmlxc/.github/workflows/lxc-test.yml@j4n/docker-support
252+
with:
253+
# TODO: revert to main once cmlxc docker support is merged
254+
cmlxc_version: j4n/docker-support
255+
cmlxc_commands: |
256+
cmlxc init
257+
cmlxc docker deploy dock0 --source ghcr:sha-${{ needs.build.outputs.relay_sha_short }}-trixie
232258
RELAY_REF=${{ needs.build.outputs.relay_ref }} cmlxc test-cmdeploy dock0

chatmail_relay.dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# syntax=docker/dockerfile:1
22

3-
# Build systemd-debian:12 base image locally
4-
# Vendoring https://github.com/j8r/dockerfiles/blob/master/systemd/debian/Dockerfile thats behind
5-
# https://hub.docker.com/r/jrei/systemd-debian/tags?name=bookworm
6-
FROM debian:12 AS systemd-base
3+
ARG DEBIAN_VERSION=12
74

8-
ARG VERSION=12
5+
# Build systemd-debian base image locally
6+
# Vendoring https://github.com/j8r/dockerfiles/blob/master/systemd/debian/Dockerfile thats behind
7+
# https://hub.docker.com/r/jrei/systemd-debian/tags
8+
FROM debian:${DEBIAN_VERSION} AS systemd-base
99

1010
ENV LC_ALL=C
1111
ENV DEBIAN_FRONTEND=noninteractive

0 commit comments

Comments
 (0)