summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2023-03-13 12:12:02 +0000
committerGitHub <noreply@github.com>2023-03-13 12:12:02 +0000
commitd4eba4409f984307485b10e6b77d5edb4d93f440 (patch)
tree045930f2d163737904d55f2dce18fe6177d3247f
parentBump hiredis from 2.2.1 to 2.2.2 (#15252) (diff)
downloadsynapse-d4eba4409f984307485b10e6b77d5edb4d93f440.tar.xz
Install rust during Stage 0 of docker build (#15239)
* Install rust during Stage 0 of docker build

Thanks to @atomdmac for spotting the fix.
Fixes #15179.

* Changelog
-rw-r--r--changelog.d/15239.docker1
-rw-r--r--docker/Dockerfile17
2 files changed, 17 insertions, 1 deletions
diff --git a/changelog.d/15239.docker b/changelog.d/15239.docker
new file mode 100644
index 0000000000..2aad329e99
--- /dev/null
+++ b/changelog.d/15239.docker
@@ -0,0 +1 @@
+Ensure the Dockerfile builds on platforms that don't have a `cryptography` wheel.
diff --git a/docker/Dockerfile b/docker/Dockerfile
index a85fd3d691..3d07bcd71f 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -37,9 +37,24 @@ RUN \
   --mount=type=cache,target=/var/cache/apt,sharing=locked \
   --mount=type=cache,target=/var/lib/apt,sharing=locked \
   apt-get update -qq && apt-get install -yqq \
-  build-essential git libffi-dev libssl-dev \
+  build-essential curl git libffi-dev libssl-dev \
   && rm -rf /var/lib/apt/lists/*
 
+# Install rust and ensure its in the PATH.
+# (Rust may be needed to compile `cryptography`---which is one of poetry's
+# dependencies---on platforms that don't have a `cryptography` wheel.
+ENV RUSTUP_HOME=/rust
+ENV CARGO_HOME=/cargo
+ENV PATH=/cargo/bin:/rust/bin:$PATH
+RUN mkdir /rust /cargo
+
+RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable --profile minimal
+
+# arm64 builds consume a lot of memory if `CARGO_NET_GIT_FETCH_WITH_CLI` is not
+# set to true, so we expose it as a build-arg.
+ARG CARGO_NET_GIT_FETCH_WITH_CLI=false
+ENV CARGO_NET_GIT_FETCH_WITH_CLI=$CARGO_NET_GIT_FETCH_WITH_CLI
+
 # We install poetry in its own build stage to avoid its dependencies conflicting with
 # synapse's dependencies.
 RUN --mount=type=cache,target=/root/.cache/pip \