From 92a29dcffc4fca0029c2f3ee63a66152c5e54e60 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Tue, 25 Mar 2025 09:57:55 -0400 Subject: [PATCH] Docker: Use an ARG for debian version more often (#18272) --- changelog.d/18272.docker | 1 + docker/Dockerfile-workers | 5 +++-- docker/complement/Dockerfile | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 changelog.d/18272.docker diff --git a/changelog.d/18272.docker b/changelog.d/18272.docker new file mode 100644 index 0000000000..ceec619b6c --- /dev/null +++ b/changelog.d/18272.docker @@ -0,0 +1 @@ +Always specify base image debian versions with a build argument. diff --git a/docker/Dockerfile-workers b/docker/Dockerfile-workers index 2ceb6ab67c..3dec4bba05 100644 --- a/docker/Dockerfile-workers +++ b/docker/Dockerfile-workers @@ -2,12 +2,13 @@ ARG SYNAPSE_VERSION=latest ARG FROM=matrixdotorg/synapse:$SYNAPSE_VERSION +ARG DEBIAN_VERSION=bookworm # first of all, we create a base image with an nginx which we can copy into the # target image. For repeated rebuilds, this is much faster than apt installing # each time. -FROM docker.io/library/debian:bookworm-slim AS deps_base +FROM docker.io/library/debian:${DEBIAN_VERSION}-slim AS deps_base RUN \ --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ @@ -21,7 +22,7 @@ FROM docker.io/library/debian:bookworm-slim AS deps_base # which makes it much easier to copy (but we need to make sure we use an image # based on the same debian version as the synapse image, to make sure we get # the expected version of libc. -FROM docker.io/library/redis:7-bookworm AS redis_base +FROM docker.io/library/redis:7-${DEBIAN_VERSION} AS redis_base # now build the final image, based on the the regular Synapse docker image FROM $FROM diff --git a/docker/complement/Dockerfile b/docker/complement/Dockerfile index ce82c400eb..3e7f808cc5 100644 --- a/docker/complement/Dockerfile +++ b/docker/complement/Dockerfile @@ -9,6 +9,9 @@ ARG SYNAPSE_VERSION=latest # This is an intermediate image, to be built locally (not pulled from a registry). ARG FROM=matrixdotorg/synapse-workers:$SYNAPSE_VERSION +ARG DEBIAN_VERSION=bookworm + +FROM docker.io/library/postgres:13-${DEBIAN_VERSION} AS postgres_base FROM $FROM # First of all, we copy postgres server from the official postgres image, @@ -20,8 +23,8 @@ FROM $FROM # the same debian version as Synapse's docker image (so the versions of the # shared libraries match). RUN adduser --system --uid 999 postgres --home /var/lib/postgresql -COPY --from=docker.io/library/postgres:13-bookworm /usr/lib/postgresql /usr/lib/postgresql -COPY --from=docker.io/library/postgres:13-bookworm /usr/share/postgresql /usr/share/postgresql +COPY --from=postgres_base /usr/lib/postgresql /usr/lib/postgresql +COPY --from=postgres_base /usr/share/postgresql /usr/share/postgresql RUN mkdir /var/run/postgresql && chown postgres /var/run/postgresql ENV PATH="${PATH}:/usr/lib/postgresql/13/bin" ENV PGDATA=/var/lib/postgresql/data