Skip to content

Commit 67f22a2

Browse files
authored
Update Docker images to use Debian trixie (13) and thus Python 3.13 (#19064)
1 parent da6c0ca commit 67f22a2

File tree

6 files changed

+39
-29
lines changed

6 files changed

+39
-29
lines changed

changelog.d/19064.docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update docker image to use Debian trixie as the base and thus Python 3.13.

docker/Dockerfile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
# `poetry export | pip install -r /dev/stdin`, but beware: we have experienced bugs in
2121
# in `poetry export` in the past.
2222

23-
ARG DEBIAN_VERSION=bookworm
24-
ARG PYTHON_VERSION=3.12
23+
ARG DEBIAN_VERSION=trixie
24+
ARG PYTHON_VERSION=3.13
2525
ARG POETRY_VERSION=2.1.1
2626

2727
###
@@ -142,10 +142,10 @@ RUN \
142142
libwebp7 \
143143
xmlsec1 \
144144
libjemalloc2 \
145-
libicu \
146145
| grep '^\w' > /tmp/pkg-list && \
147146
for arch in arm64 amd64; do \
148147
mkdir -p /tmp/debs-${arch} && \
148+
chown _apt:root /tmp/debs-${arch} && \
149149
cd /tmp/debs-${arch} && \
150150
apt-get -o APT::Architecture="${arch}" download $(cat /tmp/pkg-list); \
151151
done
@@ -176,11 +176,6 @@ LABEL org.opencontainers.image.documentation='https://element-hq.github.io/synap
176176
LABEL org.opencontainers.image.source='https://github.com/element-hq/synapse.git'
177177
LABEL org.opencontainers.image.licenses='AGPL-3.0-or-later OR LicenseRef-Element-Commercial'
178178

179-
# On the runtime image, /lib is a symlink to /usr/lib, so we need to copy the
180-
# libraries to the right place, else the `COPY` won't work.
181-
# On amd64, we'll also have a /lib64 folder with ld-linux-x86-64.so.2, which is
182-
# already present in the runtime image.
183-
COPY --from=runtime-deps /install-${TARGETARCH}/lib /usr/lib
184179
COPY --from=runtime-deps /install-${TARGETARCH}/etc /etc
185180
COPY --from=runtime-deps /install-${TARGETARCH}/usr /usr
186181
COPY --from=runtime-deps /install-${TARGETARCH}/var /var

docker/Dockerfile-workers

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1-
# syntax=docker/dockerfile:1
1+
# syntax=docker/dockerfile:1-labs
22

33
ARG SYNAPSE_VERSION=latest
44
ARG FROM=matrixdotorg/synapse:$SYNAPSE_VERSION
5-
ARG DEBIAN_VERSION=bookworm
6-
ARG PYTHON_VERSION=3.12
5+
ARG DEBIAN_VERSION=trixie
6+
ARG PYTHON_VERSION=3.13
7+
ARG REDIS_VERSION=7.2
78

89
# first of all, we create a base image with dependencies which we can copy into the
910
# target image. For repeated rebuilds, this is much faster than apt installing
1011
# each time.
1112

1213
FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-${DEBIAN_VERSION} AS deps_base
1314

15+
ARG DEBIAN_VERSION
16+
ARG REDIS_VERSION
17+
1418
# Tell apt to keep downloaded package files, as we're using cache mounts.
1519
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
1620

21+
# The upstream redis-server deb has fewer dynamic libraries than Debian's package which makes it easier to copy later on
22+
RUN \
23+
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg && \
24+
chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg && \
25+
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb ${DEBIAN_VERSION} main" | tee /etc/apt/sources.list.d/redis.list
26+
1727
RUN \
1828
--mount=type=cache,target=/var/cache/apt,sharing=locked \
1929
--mount=type=cache,target=/var/lib/apt,sharing=locked \
2030
apt-get update -qq && \
2131
DEBIAN_FRONTEND=noninteractive apt-get install -yqq --no-install-recommends \
22-
nginx-light
32+
nginx-light \
33+
redis-server="6:${REDIS_VERSION}.*" redis-tools="6:${REDIS_VERSION}.*" \
34+
# libicu is required by postgres, see `docker/complement/Dockerfile`
35+
libicu76
2336

2437
RUN \
2538
# remove default page
@@ -35,19 +48,12 @@ FROM ghcr.io/astral-sh/uv:python${PYTHON_VERSION}-${DEBIAN_VERSION} AS deps_base
3548

3649
RUN mkdir -p /uv/etc/supervisor/conf.d
3750

38-
# Similarly, a base to copy the redis server from.
39-
#
40-
# The redis docker image has fewer dynamic libraries than the debian package,
41-
# which makes it much easier to copy (but we need to make sure we use an image
42-
# based on the same debian version as the synapse image, to make sure we get
43-
# the expected version of libc.
44-
FROM docker.io/library/redis:7-${DEBIAN_VERSION} AS redis_base
45-
4651
# now build the final image, based on the the regular Synapse docker image
4752
FROM $FROM
4853

4954
# Copy over dependencies
50-
COPY --from=redis_base /usr/local/bin/redis-server /usr/local/bin
55+
COPY --from=deps_base --parents /usr/lib/*-linux-gnu/libicu* /
56+
COPY --from=deps_base /usr/bin/redis-server /usr/local/bin
5157
COPY --from=deps_base /uv /
5258
COPY --from=deps_base /usr/sbin/nginx /usr/sbin
5359
COPY --from=deps_base /usr/share/nginx /usr/share/nginx

docker/complement/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
ARG SYNAPSE_VERSION=latest
1010
# This is an intermediate image, to be built locally (not pulled from a registry).
1111
ARG FROM=matrixdotorg/synapse-workers:$SYNAPSE_VERSION
12-
ARG DEBIAN_VERSION=bookworm
12+
ARG DEBIAN_VERSION=trixie
1313

1414
FROM docker.io/library/postgres:13-${DEBIAN_VERSION} AS postgres_base
1515

@@ -18,10 +18,10 @@ FROM $FROM
1818
# since for repeated rebuilds, this is much faster than apt installing
1919
# postgres each time.
2020

21-
# This trick only works because (a) the Synapse image happens to have all the
22-
# shared libraries that postgres wants, (b) we use a postgres image based on
23-
# the same debian version as Synapse's docker image (so the versions of the
24-
# shared libraries match).
21+
# This trick only works because we use a postgres image based on the same
22+
# debian version as Synapse's docker image (so the versions of the shared
23+
# libraries match). Any missing libraries need to be added to either the
24+
# Synapse image or docker/Dockerfile-workers.
2525
RUN adduser --system --uid 999 postgres --home /var/lib/postgresql
2626
COPY --from=postgres_base /usr/lib/postgresql /usr/lib/postgresql
2727
COPY --from=postgres_base /usr/share/postgresql /usr/share/postgresql

docker/editable.Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ ARG PYTHON_VERSION=3.9
88
###
99
### Stage 0: generate requirements.txt
1010
###
11-
# We hardcode the use of Debian bookworm here because this could change upstream
12-
# and other Dockerfiles used for testing are expecting bookworm.
13-
FROM docker.io/library/python:${PYTHON_VERSION}-slim-bookworm
11+
# We hardcode the use of Debian trixie here because this could change upstream
12+
# and other Dockerfiles used for testing are expecting trixie.
13+
FROM docker.io/library/python:${PYTHON_VERSION}-slim-trixie
1414

1515
# Install Rust and other dependencies (stolen from normal Dockerfile)
1616
# install the OS build deps

docs/upgrade.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ each upgrade are complete before moving on to the next upgrade, to avoid
117117
stacking them up. You can monitor the currently running background updates with
118118
[the Admin API](usage/administration/admin_api/background_updates.html#status).
119119
120+
# Upgrading to v1.141.0
121+
122+
## Docker images now based on Debian `trixie` with Python 3.13
123+
124+
The Docker images are now based on Debian `trixie` and use Python 3.13. If you
125+
are using the Docker images as a base image you may need to e.g. adjust the
126+
paths you mount any additional Python packages at.
127+
120128
# Upgrading to v1.140.0
121129
122130
## Users of `synapse-s3-storage-provider` must update the module to `v1.6.0`

0 commit comments

Comments
 (0)