From c02d4349a334ae265bf0f2a009538050e9a431b5 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Tue, 10 May 2022 15:55:30 +0100 Subject: [PATCH] Get ARM64 builds working (#339) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use node:16-slim for final image build * changelog * Add ignore scripts to final install step * Copy matrix-sdk-crypto-nodejs built files * Add workaround to build images foo crypto-nodejs * chmod +x * require bash for builds * Add apt install to hopefully make the rust bits build for arm * Fix missing multilib (#349) * Update and rename 336.misc to 339.bugfix Co-authored-by: Paul Tötterman --- Dockerfile | 9 +++++++++ changelog.d/339.bugfix | 1 + scripts/build-app.sh | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 changelog.d/339.bugfix diff --git a/Dockerfile b/Dockerfile index 4b3fbe66..5da4ad04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,11 +10,16 @@ WORKDIR /src RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal ENV PATH="/root/.cargo/bin:${PATH}" +# Needed to build rust things for matrix-sdk-crypto-nodejs +# See https://github.com/matrix-org/matrix-rust-sdk-bindings/blob/main/crates/matrix-sdk-crypto-nodejs/release/Dockerfile.linux#L5-L6 +RUN apt-get update && apt-get install -y build-essential cmake + # Workaround: Need to install esbuild manually https://github.com/evanw/esbuild/issues/462#issuecomment-771328459 RUN yarn --ignore-scripts RUN node node_modules/esbuild/install.js RUN yarn build --pure-lockfile + # Stage 1: The actual container FROM node:16-slim @@ -23,9 +28,13 @@ COPY --from=builder /src/public/ /bin/matrix-hookshot/public/ COPY --from=builder /src/package.json /bin/matrix-hookshot/ COPY --from=builder /src/yarn.lock /bin/matrix-hookshot/ WORKDIR /bin/matrix-hookshot + # --ignore-scripts so we don't try to build RUN yarn --ignore-scripts --production --pure-lockfile && yarn cache clean +# Copy rust bindings for crypto, since we built them in the previous step. +COPY --from=builder /src/node_modules/@turt2live/matrix-sdk-crypto-nodejs /bin/matrix-hookshot/node_modules/@turt2live/matrix-sdk-crypto-nodejs + VOLUME /data EXPOSE 9993 EXPOSE 7775 diff --git a/changelog.d/339.bugfix b/changelog.d/339.bugfix new file mode 100644 index 00000000..8e70f053 --- /dev/null +++ b/changelog.d/339.bugfix @@ -0,0 +1 @@ +Docker images can now be built cross-platform. Thanks @ptman for getting arm64 builds going! diff --git a/scripts/build-app.sh b/scripts/build-app.sh index 8dc3d158..e60096f1 100755 --- a/scripts/build-app.sh +++ b/scripts/build-app.sh @@ -1,8 +1,14 @@ -#!/bin/sh +#!/bin/bash # exit when any command fails set -e +# Workaround for non-x64 / ia32 targets +pushd node_modules/@turt2live/matrix-sdk-crypto-nodejs +echo "Checking matrix-sdk-crypto-nodejs bindings (and building if required)" +node check-exists.js +popd + echo "Building Rust layer" yarn run build:app:rs echo "Running rust-typescript definitions fix"