Skip to content

Commit db0a9a5

Browse files
authored
Use bookworm; target specific Python & PostgreSQL (#1414)
Update dependencies to comply with Synapse's deprecation policy: https://element-hq.github.io/synapse/latest/deprecation_policy.html - Upgrade to Debian Bookworm (the current oldstable) to pull in the oldest supported version of SQLite. - Instead of installing PostgreSQL from Debian repositories, use the PostgreSQL Apt Repository to install its lowest-supported version. - Instead of installing Python from Debian repositories, use uv to install its lowest-supported version.
1 parent 419cea5 commit db0a9a5

File tree

6 files changed

+59
-39
lines changed

6 files changed

+59
-39
lines changed

.github/workflows/docker.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ jobs:
2323
strategy:
2424
matrix:
2525
include:
26-
- base_image: debian:bullseye
27-
tag: bullseye
28-
- base_image: debian:testing
29-
tag: testing
26+
- tag: bookworm
27+
build_args: |
28+
BASE_IMAGE=debian:bookworm
29+
POSTGRESQL_VERSION=13
30+
- tag: testing
31+
build_args: |
32+
BASE_IMAGE=debian:testing
33+
POSTGRESQL_VERSION=18
3034
steps:
3135
- name: Set up QEMU
3236
id: QEMU
@@ -53,7 +57,7 @@ jobs:
5357
platforms: linux/amd64,linux/arm64
5458
labels: "gitsha1=${{ github.sha }}"
5559
file: docker/base.Dockerfile
56-
build-args: "BASE_IMAGE=${{ matrix.base_image }}"
60+
build-args: ${{ matrix.build_args }}
5761
tags: matrixdotorg/sytest:${{ matrix.tag }}
5862

5963
build-dependent-images:
@@ -63,16 +67,18 @@ jobs:
6367
strategy:
6468
matrix:
6569
include:
66-
- sytest_image_tag: bullseye
70+
- sytest_image_tag: bookworm
6771
dockerfile: synapse
68-
tags: "matrixdotorg/sytest-synapse:bullseye"
69-
build_args: "SYTEST_IMAGE_TAG=bullseye"
72+
tags: "matrixdotorg/sytest-synapse:bookworm"
73+
build_args: |
74+
SYTEST_IMAGE_TAG=bookworm
75+
PYTHON_VERSION=3.10
7076
- sytest_image_tag: testing
7177
dockerfile: synapse
7278
tags: "matrixdotorg/sytest-synapse:testing"
7379
build_args: |
7480
SYTEST_IMAGE_TAG=testing
75-
SYSTEM_PIP_INSTALL_SUFFIX=--break-system-packages
81+
PYTHON_VERSION=3.13
7682
7783
steps:
7884
- name: Set up QEMU

.github/workflows/pipeline.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,26 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
include:
24-
- label: Debian Bullseye (Py 3.9, SQLite) Monolith
25-
sytest-tag: bullseye
24+
- label: Debian Bookworm (Py 3.10, SQLite 3.40) Monolith
25+
sytest-tag: bookworm
2626

27-
- label: Debian Bullseye (Py 3.9, PG 13) Monolith
28-
sytest-tag: bullseye
27+
- label: Debian Bookworm (Py 3.10, PG 13) Monolith
28+
sytest-tag: bookworm
2929
postgres: postgres
3030

31-
- label: Debian Bullseye (Py 3.9, PG 13) Workers
32-
sytest-tag: bullseye
31+
- label: Debian Bookworm (Py 3.10, PG 13) Workers
32+
sytest-tag: bookworm
3333
postgres: postgres
3434
workers: workers
3535

36-
- label: Debian Testing (Py 3.13, PG 17), Monolith
36+
- label: Debian Testing (Py 3.13, SQLite 3.46) Monolith
37+
sytest-tag: testing
38+
39+
- label: Debian Testing (Py 3.13, PG 18), Monolith
3740
sytest-tag: testing
3841
postgres: postgres
3942

40-
- label: Debian Testing (Py 3.13, PG 17), Workers
43+
- label: Debian Testing (Py 3.13, PG 18), Workers
4144
sytest-tag: testing
4245
postgres: postgres
4346
workers: workers

docker/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ but its dependencies are.
88
Included currently is:
99

1010
- `matrixdotorg/sytest` Base container with SyTest dependencies installed
11-
- Tagged by underlying Debian/Ubuntu image: `bullseye` or `testing`
11+
- Tagged by underlying Debian/Ubuntu image: `bookworm` or `testing`
1212
- `matrixdotorg/sytest-synapse`: Runs SyTest against Synapse
13-
- Tagged by underlying Debian/Ubuntu image: `bullseye` or `testing`
13+
- Tagged by underlying Debian/Ubuntu image: `bookworm` or `testing`
1414

1515
## Target-specific details
1616

@@ -23,7 +23,7 @@ it is useful to mount a volume there too.
2323
For example:
2424

2525
```
26-
docker run --rm -it -v /path/to/synapse\:/src:ro -v /path/to/where/you/want/logs\:/logs matrixdotorg/sytest-synapse:bullseye
26+
docker run --rm -it -v /path/to/synapse\:/src:ro -v /path/to/where/you/want/logs\:/logs matrixdotorg/sytest-synapse:bookworm
2727
```
2828

2929
The following environment variables can be set with `-e` to control the test run:
@@ -47,7 +47,7 @@ An example of running Synapse in worker mode:
4747

4848
```
4949
docker run --rm -it -e POSTGRES=1 -e WORKERS=1 -v /path/to/synapse\:/src:ro \
50-
-v /path/to/where/you/want/logs\:/logs matrixdotorg/sytest-synapse:bullseye
50+
-v /path/to/where/you/want/logs\:/logs matrixdotorg/sytest-synapse:bookworm
5151
```
5252

5353
### Dendrite
@@ -72,7 +72,7 @@ for example:
7272
docker run --rm -it \
7373
-e SYTEST_BRANCH="my-sytest-branch"
7474
-v /path/to/synapse\:/src:ro -v /path/to/where/you/want/logs\:/logs
75-
matrixdotorg/sytest-synapse:bullseye
75+
matrixdotorg/sytest-synapse:bookworm
7676
```
7777

7878
If the branch referred to by `SYTEST_BRANCH` does not exist, `develop` is used
@@ -84,7 +84,7 @@ the container:
8484

8585
```
8686
docker run --rm -it -v /path/to/synapse\:/src:ro -v /path/to/where/you/want/logs\:/logs \
87-
-v /path/to/code/sytest\:/sytest:ro matrixdotorg/sytest-synapse:bullseye
87+
-v /path/to/code/sytest\:/sytest:ro matrixdotorg/sytest-synapse:bookworm
8888
```
8989

9090
## Running a single test file, and other sytest commandline options
@@ -93,7 +93,7 @@ You can pass arguments to sytest by adding them at the end of the
9393
docker command. For example:
9494

9595
```
96-
docker run --rm -it ... matrixdotorg/sytest-synapse:bullseye tests/20profile-events.pl
96+
docker run --rm -it ... matrixdotorg/sytest-synapse:bookworm tests/20profile-events.pl
9797
```
9898

9999
## Building the containers

docker/base.Dockerfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG BASE_IMAGE=debian:bullseye
1+
ARG BASE_IMAGE=debian:bookworm
22

33
FROM ${BASE_IMAGE}
44

@@ -20,14 +20,23 @@ RUN apt-get -qq update && apt-get -qq install -y \
2020
libz-dev \
2121
locales \
2222
perl \
23-
postgresql \
23+
postgresql-common \
2424
rsync \
2525
sqlite3 \
2626
wget \
2727
libicu-dev \
2828
pkg-config \
2929
&& rm -rf /var/lib/apt/lists/*
3030

31+
# Set the default PostgreSQL version to the minimum supported by Synapse:
32+
# https://element-hq.github.io/synapse/latest/deprecation_policy.html
33+
ARG POSTGRESQL_VERSION=13
34+
# Install a specific PostgreSQL version via the official upstream repository:
35+
# https://wiki.debian.org/PostgreSql%20%20#PGDG_Repository
36+
RUN /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y \
37+
&& apt -qq install -y postgresql-${POSTGRESQL_VERSION} \
38+
&& rm -rf /var/lib/apt/lists/*
39+
3140
# Set up the locales, as the default Debian image only has C, and PostgreSQL needs the correct locales to make a UTF-8 database
3241
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
3342
dpkg-reconfigure --frontend=noninteractive locales && \

docker/dendrite.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG SYTEST_IMAGE_TAG=bullseye
1+
ARG SYTEST_IMAGE_TAG=bookworm
22
FROM matrixdotorg/sytest:${SYTEST_IMAGE_TAG}
33

44
ARG GO_VERSION=1.19.1

docker/synapse.Dockerfile

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
ARG SYTEST_IMAGE_TAG=bullseye
1+
ARG SYTEST_IMAGE_TAG=bookworm
22

33
FROM matrixdotorg/sytest:${SYTEST_IMAGE_TAG}
44

5-
ARG PYTHON_VERSION=python3
6-
ARG SYSTEM_PIP_INSTALL_SUFFIX=""
7-
85
ENV DEBIAN_FRONTEND noninteractive
96

107
# Ensure we die correctly when using pipes in RUN.
118
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
129

1310
RUN apt-get -qq update && apt-get -qq install -y \
14-
apt-utils ${PYTHON_VERSION} ${PYTHON_VERSION}-dev ${PYTHON_VERSION}-venv \
15-
python3-pip eatmydata redis-server curl
11+
apt-utils eatmydata redis-server curl \
12+
&& rm -rf /var/lib/apt/lists/*
1613

1714
ENV RUSTUP_HOME=/rust
1815
ENV CARGO_HOME=/cargo
@@ -21,10 +18,15 @@ RUN mkdir /rust /cargo
2118

2219
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable --profile minimal
2320

24-
# For now, we need to tell Debian we don't care that we're editing the system python
25-
# installation.
26-
# Some context in https://github.com/pypa/pip/issues/11381#issuecomment-1399263627
27-
RUN ${PYTHON_VERSION} -m pip install -q --no-cache-dir poetry==1.3.2 ${SYSTEM_PIP_INSTALL_SUFFIX}
21+
# Set the default Python version to the minimum supported by Synapse:
22+
# https://element-hq.github.io/synapse/latest/deprecation_policy.html
23+
ARG PYTHON_VERSION=3.10
24+
25+
RUN --mount=type=bind,from=ghcr.io/astral-sh/uv:0.9.4,source=/uv,target=/bin/uv \
26+
uv python install "$PYTHON_VERSION" && \
27+
uv tool install [email protected]
28+
29+
ENV PATH=/root/.local/bin:$PATH
2830

2931
# As part of the Docker build, we attempt to pre-install Synapse's dependencies
3032
# in the hope that it speeds up the real install of Synapse. To make this work,
@@ -45,7 +47,7 @@ RUN mkdir /src
4547

4648
# Download a cache of build dependencies to support offline mode.
4749
# These version numbers are arbitrary and were the latest at the time.
48-
RUN ${PYTHON_VERSION} -m pip download --dest /pypi-offline-cache \
50+
RUN "python${PYTHON_VERSION}" -m pip download --dest /pypi-offline-cache \
4951
poetry-core==1.1.0 setuptools==65.3.0 wheel==0.37.1 \
5052
setuptools-rust==1.5.1
5153

@@ -57,7 +59,7 @@ RUN wget -q https://github.com/element-hq/synapse/archive/develop.tar.gz \
5759
tar -C /synapse --strip-components=1 -xf synapse.tar.gz && \
5860
ln -s -T /venv /synapse/.venv && \
5961
cd /synapse && \
60-
poetry install -q --no-root --extras all && \
62+
poetry install --no-root --extras all && \
6163
# Finally clean up the poetry cache and the copy of Synapse.
6264
# This must be done in the same RUN command, otherwise intermediate layers
6365
# of the Docker image will contain all the unwanted files we think we've

0 commit comments

Comments
 (0)