-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
docker builds broken on armv7 #9403
Comments
The immediate fix is presumably either to pin |
...or drop ARMv7 Docker images? Do we have any usage stats? |
Hm. Apparently Raspberry Pis still ship with a 32-bit (ARMv7) kernel, even if the host processor is 64-bit, so we do need to get armv7 builds working again. |
if our goal is simply targetting raspberry pis, we could plausibly pull wheels from https://www.piwheels.org/. |
Okay, let's:
Of note, our builds use the |
Cryptography 3.4.5 has reduced its minimum supported Rust version to 1.41, so we should be fine on that front. |
Actually, ...so I suspect we can just jam |
This is needed to build the cryptography library, since it does not provide wheels for ARMv7. Fixes matrix-org#9403 Signed-off-by: Dan Callahan <danc@element.io>
This is needed to build the cryptography library, since it does not provide wheels for ARMv7. Fixes #9403 Signed-off-by: Dan Callahan <danc@element.io>
I think this is fixed? |
Oh how I wish it were. Building Docker images on native ARMv7 hosts should work just fine. Cross-building with qemu fails, which means normal Erik traced it to an upstream bug in qemu which has been known for a couple of years. Erik also proposed a patch to our Dockerfile with the caveat "but that breaks standard docker builds :/" However, it does seem to work fine for me locally for both buildx and normal builds. ...but do we want to carry this debt, versus just dropping ARMv7l? diff --git a/docker/Dockerfile b/docker/Dockerfile
index d619ee08e..289bc3c74 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -14,7 +14,35 @@
ARG PYTHON_VERSION=3.8
###
-### Stage 0: builder
+### Stage: prebuilder
+###
+### New versions of cryptography require rust to be installed, but due to
+### https://bugs.launchpad.net/qemu/+bug/1805913 downloading cargo registries
+### and dependencies doesn't work on multiarch builds. We fix this by
+### prebuilding `cryptography` first in the native arch, and then copying over
+### the registry and running cargo in offline mode.
+###
+FROM --platform=$BUILDPLATFORM docker.io/python:${PYTHON_VERSION}-slim as prebuilder
+
+RUN apt-get update && apt-get install -y \
+ build-essential \
+ libffi-dev \
+ libssl-dev \
+ rustc \
+ zlib1g-dev \
+ && rm -rf /var/lib/apt/lists/*
+
+RUN mkdir /root/.cargo
+ENV CARGO_HOME=/root/.cargo
+
+RUN pip download --no-binary :all: --no-deps cryptography
+
+RUN tar -xf cryptography*.tar.gz --wildcards cryptography*/src/rust/
+
+RUN cd cryptography*/src/rust && cargo fetch
+
+###
+### Stage: builder
###
FROM docker.io/python:${PYTHON_VERSION}-slim as builder
@@ -32,6 +60,14 @@ RUN apt-get update && apt-get install -y \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
+COPY --from=prebuilder /root/.cargo /root/.cargo
+
+ENV CARGO_NET_OFFLINE=true
+ENV CARGO_HOME=/root/.cargo
+
+RUN pip install --prefix="/install" --no-warn-script-location \
+ cryptography
+
# Build dependencies that are not available as wheels, to speed up rebuilds
RUN pip install --prefix="/install" --no-warn-script-location \
cryptography \
@@ -57,7 +93,7 @@ RUN pip install --prefix="/install" --no-warn-script-location \
/synapse[all]
###
-### Stage 1: runtime
+### Stage: runtime
###
FROM docker.io/python:${PYTHON_VERSION}-slim |
Okay, so normal builds are broken unless you enable BuildKit. Which is fine (BuildKit is awesome!), but also this is feeling like a lot of complexity and technical debt to support a platform. |
I'm fine with either accepting the patch as-is, or dropping ARMv7 altogether. Raspberry Pi users should be able to |
I vote for keeping docker support for ARMv7, but knocking it down from a release-blocker (for normal releases, but not for security releases), and making that explicit. I think the future for raspberry-pi-based homeservers are other implementations than synapse (as synapse is increasingly aimed at large deployments, and it's requirements start to aim more towards that), but i think for the time being we should at least consider supporting them, just on a backburner. Also, couldn't we add piwheels to the docker build for ARMv7 to avoid building |
Alternative patch from Erik which doesn't require BuildKit diff --git a/docker/Dockerfile b/docker/Dockerfile
index d619ee08e..ce404662c 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 \ And then you'd build a separate base image (see below) and use it by passing diff --git a/docker/Dockerfile-cargo-cache b/docker/Dockerfile-cargo-cache
new file mode 100644
index 000000000..b4673fff5
--- /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 So we'll have to decide on a path forward, but it seems like consensus is along the lines of making ARM a tier 2 platform: best effort, but we'll ship releases like 1.27 without them. |
Ah, so there will be no arm64 images for 1.27? :( |
Probably. Our CI is effectively set up as:
So if either ARM architecture fails, we don't publish any ARM images. And our current assumption is that there's no easy way to modify existing Docker Hub listings to add additional architectures... so to optionally publish arm64 even when v7 fails, we'd need a three stage build process:
Since all the ARM stuff is happening under qemu, it takes a very long time to build. So that's unlikely to be a way forward. If we're missing something fundamental about how Docker handle multi-arch, please do let us know :) |
Ah, then I might have a solution! :D As opposed to building and re-building the images, you could simply build and publish each image separately and tag each as Only thing with that is, the final manifest would need to be published either after everything is built, thereby slowing down the release of the amd64 image (only theoretically, it would still exist under the Not sure if the above was understandable enough, so to hopefully clarify, I can point you towards a CI file I had set up earlier for one of my projects: https://github.com/TR-SLimey/DroneExternalConfig/blob/master/drone.yml Notice how in the above, the ARM build is commented out but everything works just fine. Of course that works on Drone CI and not Circle CI which I think is what you're using, but maybe you can figure something out for Circle? Edit: In case the Drone plugin docs are of any use to you, here they are also: Manifest, Docker Build. |
All that said, in trying to do some reading on multi-arch docker, it looks like the A few links in my "read later" pile:
|
In chat Rich brought up the question of what we should do with the |
Maybe you could create more tags? |
Note that due to the difficulty in getting these to build reliably we've dropped the ARM/v7 build of Synapse for the moment (as of Synapse v1.27.0). |
Docker Hub is showing |
Unfortunately, our build scripts only update Fortunately, the delayed release of 1.27 means 1.28 (with a proper |
The decision to drop ARMv7 builds was discussed in the 1.27 release announcement. I'll go ahead and close this issue now. Expect a formal release of 1.28 (with ARM64) images in the next 48 hours. |
The platform has issues building a cryptography wheel; see e.g. matrix-org/synapse#9403
Just in case, synapse doesn't build on piwheels anymore, which was one of the solutions provided when dropping armv7 support. The remaining solutions being:
We can still apparently use https://hub.docker.com/r/asonix/synapse which I haven't tried (as a side note, the official image boasts armv7 support, when it's actually deprecated) This doesn't seem like a reasonably painless experience to start using matrix. |
Our Docker build is currently broken on armv7, since python-cryptography now requires a rust compiler to build:
From https://app.circleci.com/pipelines/github/matrix-org/synapse/19720/workflows/47040f65-8516-4995-b250-9cae722e4efc/jobs/25662:
amd64 and arm64 are fine, because we use precompiled wheels from PyPI.
(see also pyca/cryptography#5771)
The text was updated successfully, but these errors were encountered: