@@ -3,8 +3,9 @@ ARG TOKENSERVER_DATABASE_BACKEND=mysql
33# Alternatively MYSQLCLIENT_PKG=libmysqlclient-dev for the Oracle/MySQL official client
44ARG MYSQLCLIENT_PKG=libmariadb-dev-compat
55
6- # NOTE: Ensure builder's Rust version matches CI's in .circleci/config.yml
7- # RUST_VER
6+ FROM python:3.14-bookworm AS python-base
7+
8+ # NOTE: Ensure builder's Rust version matches CI's in .github/ directory.
89FROM docker.io/lukemathwalker/cargo-chef:0.1.73-rust-1.91.1-bookworm AS chef
910WORKDIR /app
1011
@@ -17,26 +18,28 @@ ARG SYNCSTORAGE_DATABASE_BACKEND
1718ARG TOKENSERVER_DATABASE_BACKEND
1819ARG MYSQLCLIENT_PKG
1920
21+ COPY --from=python-base /usr/local /usr/local
22+
2023RUN apt-get -q update && \
2124 MYSQL_PKG="" && \
2225 POSTGRES_DEV_PKG="" && \
2326 if [ "$SYNCSTORAGE_DATABASE_BACKEND" = "mysql" ] || [ "$TOKENSERVER_DATABASE_BACKEND" = "mysql" ]; then \
24- MYSQL_PKG="$MYSQLCLIENT_PKG" ; \
25- if [ "$MYSQLCLIENT_PKG" = libmysqlclient-dev ] ; then \
26- # First install gnupg and setup MySQL repo
27- # Key ID A8D3785C from https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
28- apt-get -q install -y --no-install-recommends gnupg ca-certificates && \
29- echo "deb https://repo.mysql.com/apt/debian/ bookworm mysql-8.0" >> /etc/apt/sources.list && \
30- # Fetch and install the MySQL public key
31- gpg --batch --keyserver hkp://keyserver.ubuntu.com --recv-keys A8D3785C && \
32- gpg --batch --armor --export A8D3785C | tee /etc/apt/trusted.gpg.d/mysql.asc && \
33- apt-get -q update ; \
34- fi; \
27+ MYSQL_PKG="$MYSQLCLIENT_PKG" ; \
28+ if [ "$MYSQLCLIENT_PKG" = libmysqlclient-dev ] ; then \
29+ # First install gnupg and setup MySQL repo
30+ # Key ID A8D3785C from https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
31+ apt-get -q install -y --no-install-recommends gnupg ca-certificates && \
32+ echo "deb https://repo.mysql.com/apt/debian/ bookworm mysql-8.0" >> /etc/apt/sources.list && \
33+ # Fetch and install the MySQL public key
34+ gpg --batch --keyserver hkp://keyserver.ubuntu.com --recv-keys A8D3785C && \
35+ gpg --batch --armor --export A8D3785C | tee /etc/apt/trusted.gpg.d/mysql.asc && \
36+ apt-get -q update ; \
37+ fi; \
3538 fi && \
3639 if [ "$TOKENSERVER_DATABASE_BACKEND" = "postgres" ]; then \
37- POSTGRES_DEV_PKG="libpq-dev" ; \
40+ POSTGRES_DEV_PKG="libpq-dev" ; \
3841 fi && \
39- apt-get -q install -y --no-install-recommends $MYSQL_PKG $POSTGRES_DEV_PKG cmake python3-dev python3-pip python3-setuptools python3-wheel python3-venv pkg-config && \
42+ apt-get -q install -y --no-install-recommends $MYSQL_PKG $POSTGRES_DEV_PKG cmake pkg-config && \
4043 rm -rf /var/lib/apt/lists/*
4144
4245COPY --from=planner /app/recipe.json recipe.json
@@ -47,7 +50,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
4750 set -x && \
4851 TOKENSERVER_FEATURES="" && \
4952 if [ "$TOKENSERVER_DATABASE_BACKEND" = "postgres" ]; then \
50- TOKENSERVER_FEATURES="--features=tokenserver-db/postgres" ; \
53+ TOKENSERVER_FEATURES="--features=tokenserver-db/postgres" ; \
5154 fi && \
5255 cargo chef cook --release --no-default-features --features=syncstorage-db/$SYNCSTORAGE_DATABASE_BACKEND $TOKENSERVER_FEATURES --features=py_verifier --recipe-path recipe.json
5356
@@ -73,11 +76,11 @@ RUN poetry export --no-interaction --without dev --output requirements.txt --wit
7376 poetry export --no-interaction --without dev --output requirements.txt --without-hashes && \
7477 cd /app/tools/postgres && \
7578 if [ "$SYNCSTORAGE_DATABASE_BACKEND" = "postgres" ]; then \
76- poetry export --no-interaction --without dev --output requirements.txt --without-hashes; \
79+ poetry export --no-interaction --without dev --output requirements.txt --without-hashes; \
7780 else \
78- # Because we can't conditionally COPY files in the next stage, generate
79- # this empty requirements.txt file so that we can always COPY it
80- touch requirements.txt; \
81+ # Because we can't conditionally COPY files in the next stage, generate
82+ # this empty requirements.txt file so that we can always COPY it
83+ touch requirements.txt; \
8184 fi && \
8285 cd /app
8386
@@ -87,7 +90,7 @@ RUN mkdir -p /app/wheels && \
8790 pip3 wheel --no-cache-dir -r /app/tools/integration_tests/requirements.txt -w /app/wheels && \
8891 pip3 wheel --no-cache-dir -r /app/tools/tokenserver/requirements.txt -w /app/wheels && \
8992 if [ "$SYNCSTORAGE_DATABASE_BACKEND" = "postgres" ] && [ -f /app/tools/postgres/requirements.txt ]; then \
90- pip3 wheel --no-cache-dir -r /app/tools/postgres/requirements.txt -w /app/wheels; \
93+ pip3 wheel --no-cache-dir -r /app/tools/postgres/requirements.txt -w /app/wheels; \
9194 fi
9295
9396ENV PATH=$PATH:/root/.cargo/bin
@@ -98,13 +101,13 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
98101 set -x && \
99102 TOKENSERVER_FEATURES="" && \
100103 if [ "$TOKENSERVER_DATABASE_BACKEND" = "postgres" ]; then \
101- TOKENSERVER_FEATURES="--features=tokenserver-db/postgres" ; \
104+ TOKENSERVER_FEATURES="--features=tokenserver-db/postgres" ; \
102105 fi && \
103106 cargo --version && \
104107 rustc --version && \
105108 cargo install --path ./syncserver --no-default-features --features=syncstorage-db/$SYNCSTORAGE_DATABASE_BACKEND $TOKENSERVER_FEATURES --features=py_verifier --locked --root /app
106109
107- FROM docker.io/library/debian:bookworm -slim
110+ FROM python:3.14 -slim-bookworm
108111ARG SYNCSTORAGE_DATABASE_BACKEND
109112ARG TOKENSERVER_DATABASE_BACKEND
110113ARG MYSQLCLIENT_PKG
@@ -115,21 +118,16 @@ RUN apt-get -q update && \
115118 # Always install MySQL libs because Python integration tests depend on mysqlclient
116119 MYSQL_PKG="$MYSQLCLIENT_PKG" && \
117120 if [ "$MYSQLCLIENT_PKG" = libmysqlclient-dev ] ; then \
118- # First install gnupg and setup MySQL repo
119- apt-get install -y --no-install-recommends gnupg ca-certificates wget && \
120- echo "deb https://repo.mysql.com/apt/debian/ bookworm mysql-8.0" >> /etc/apt/sources.list && \
121- # Fetch and install the MySQL public key
122- gpg --batch --keyserver hkp://keyserver.ubuntu.com --recv-keys A8D3785C && \
123- gpg --batch --armor --export A8D3785C | tee /etc/apt/trusted.gpg.d/mysql.asc && \
124- apt-get -q update ; \
121+ # First install gnupg and setup MySQL repo
122+ apt-get install -y --no-install-recommends gnupg ca-certificates wget && \
123+ echo "deb https://repo.mysql.com/apt/debian/ bookworm mysql-8.0" >> /etc/apt/sources.list && \
124+ # Fetch and install the MySQL public key
125+ gpg --batch --keyserver hkp://keyserver.ubuntu.com --recv-keys A8D3785C && \
126+ gpg --batch --armor --export A8D3785C | tee /etc/apt/trusted.gpg.d/mysql.asc && \
127+ apt-get -q update ; \
125128 fi && \
126129 POSTGRES_PKG="libpq5" && \
127- apt-get -q install -y --no-install-recommends $MYSQL_PKG $POSTGRES_PKG libssl3 libffi8 libcurl4 libpython3.11 python3 python3-pip python3-venv curl jq && \
128- # The python3-cryptography debian package installs version 2.6.1, but we
129- # we want to use the version specified in requirements.txt. To do this,
130- # we have to remove the python3-cryptography package here.
131- apt-get -q remove -y python3-cryptography 2>/dev/null || true && \
132- apt-get -q autoremove -y && \
130+ apt-get -q install -y --no-install-recommends $MYSQL_PKG $POSTGRES_PKG libssl3 libffi8 libcurl4 curl jq && \
133131 rm -rf /var/lib/apt/lists/*
134132
135133WORKDIR /app
@@ -144,11 +142,12 @@ COPY --from=builder /app/wheels /tmp/wheels
144142RUN groupadd --gid 10001 app && \
145143 useradd --uid 10001 --gid 10001 --home /app --create-home app
146144
147- RUN pip3 install --break-system-packages --no-cache-dir --no-index --find-links=/tmp/wheels -r /app/requirements.txt && \
145+ RUN pip3 install --break-system-packages --no-cache-dir "setuptools>=75.0.0" && \
146+ pip3 install --break-system-packages --no-cache-dir --no-index --find-links=/tmp/wheels -r /app/requirements.txt && \
148147 pip3 install --break-system-packages --no-cache-dir --no-index --find-links=/tmp/wheels -r /app/tools/integration_tests/requirements.txt && \
149148 pip3 install --break-system-packages --no-cache-dir --no-index --find-links=/tmp/wheels -r /app/tools/tokenserver/requirements.txt && \
150149 if [ "$SYNCSTORAGE_DATABASE_BACKEND" = "postgres" ] && [ -f /app/tools/postgres/requirements.txt ]; then \
151- pip3 install --break-system-packages --no-cache-dir --no-index --find-links=/tmp/wheels -r /app/tools/postgres/requirements.txt; \
150+ pip3 install --break-system-packages --no-cache-dir --no-index --find-links=/tmp/wheels -r /app/tools/postgres/requirements.txt; \
152151 fi && \
153152 rm -rf /tmp/wheels /root/.cache/pip
154153
0 commit comments