summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2021-02-17 15:09:45 +0000
committerErik Johnston <erik@matrix.org>2021-02-17 15:09:45 +0000
commitb64dadc4979a3d9f1de6399a02f28fe247b36157 (patch)
tree9e9079985e61936d76dfc9b7dcdcf1b7d4e386b7
parentSupport for form_post in OIDC responses (#9376) (diff)
downloadsynapse-b64dadc4979a3d9f1de6399a02f28fe247b36157.tar.xz
Add a Dockerfile that allows using a base image with a cargo cache
-rw-r--r--docker/Dockerfile6
-rw-r--r--docker/Dockerfile-cargo-cache21
2 files changed, 26 insertions, 1 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile

index d619ee08ed..ce404662ce 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile
@@ -12,11 +12,13 @@ # ARG PYTHON_VERSION=3.8 +ARG BASE_IMAGE=docker.io/python:${PYTHON_VERSION}-slim +ARG CARGO_NET_OFFLINE=false ### ### Stage 0: builder ### -FROM docker.io/python:${PYTHON_VERSION}-slim as builder +FROM ${BASE_IMAGE} as builder # install the OS build deps RUN apt-get update && apt-get install -y \ @@ -32,6 +34,8 @@ RUN apt-get update && apt-get install -y \ zlib1g-dev \ && rm -rf /var/lib/apt/lists/* +ENV CARGO_NET_OFFLINE=${CARGO_NET_OFFLINE} + # Build dependencies that are not available as wheels, to speed up rebuilds RUN pip install --prefix="/install" --no-warn-script-location \ cryptography \ diff --git a/docker/Dockerfile-cargo-cache b/docker/Dockerfile-cargo-cache new file mode 100644
index 0000000000..b4673fff53 --- /dev/null +++ b/docker/Dockerfile-cargo-cache
@@ -0,0 +1,21 @@ +# A docker file that caches the cargo index for the cryptography deps. This is +# mainly useful for multi-arch builds where fetching the index from the internet +# fails for 32bit archs built on 64 bit platforms. + +ARG PYTHON_VERSION=3.8 + +FROM --platform=$BUILDPLATFORM docker.io/python:${PYTHON_VERSION}-slim as builder + +RUN apt-get update && apt-get install -y \ + rustc \ + && rm -rf /var/lib/apt/lists/* + +RUN pip download --no-binary cryptography --no-deps cryptography + +RUN tar -xf cryptography*.tar.gz --wildcards cryptography*/src/rust/ + +RUN cd cryptography*/src/rust && cargo fetch + +FROM docker.io/python:${PYTHON_VERSION}-slim + +COPY --from=builder /root/.cargo /root/.cargo