Make arm faster build

This commit is contained in:
Ethan O'Brien
2026-06-11 19:59:03 -05:00
parent bfa9a12194
commit 87109005bb
2 changed files with 28 additions and 25 deletions

View File

@@ -16,12 +16,6 @@ jobs:
with: with:
node-version: '18' node-version: '18'
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
@@ -61,8 +55,5 @@ jobs:
docker.io/ethanaobrien/ew:${{ env.APP_VERSION }} docker.io/ethanaobrien/ew:${{ env.APP_VERSION }}
file: "docker/Dockerfile" file: "docker/Dockerfile"
platforms: linux/amd64, linux/arm64 platforms: linux/amd64, linux/arm64
cache-from: type=gha
# arm64 builds OOM without the git fetch setting. c.f. cache-to: type=gha,mode=max
# https://github.com/rust-lang/cargo/issues/10583
build-args: |
CARGO_NET_GIT_FETCH_WITH_CLI=true

View File

@@ -1,26 +1,38 @@
FROM docker.io/library/debian:latest AS builder # syntax=docker/dockerfile:1
# First - build
RUN apt update && apt install -y curl libssl-dev perl git gcc make FROM --platform=$BUILDPLATFORM rust:bookworm AS builder
RUN curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable --profile minimal
WORKDIR /ew/ ARG TARGETARCH
COPY ./ ./ WORKDIR /ew
WORKDIR /ew/ RUN apt-get update \
&& case "$TARGETARCH" in \
amd64) echo x86_64-unknown-linux-gnu > /rust-target ;; \
arm64) apt-get install -y --no-install-recommends \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
&& rustup target add aarch64-unknown-linux-gnu \
&& echo aarch64-unknown-linux-gnu > /rust-target ;; \
*) echo "Unsupported TARGETARCH: $TARGETARCH" >&2; exit 1 ;; \
esac \
&& rm -rf /var/lib/apt/lists/*
RUN . "$HOME/.cargo/env" && cargo build --release ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \
AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar
## Second - sort stuff idk COPY . .
# Cache
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,target=/ew/target,id=ew-target-${TARGETARCH},sharing=locked \
cargo build --release --target "$(cat /rust-target)" \
&& cp "target/$(cat /rust-target)/release/ew" /usr/local/bin/ew
FROM docker.io/library/debian:bookworm-slim FROM docker.io/library/debian:bookworm-slim
RUN mkdir -p /root/ew/ COPY --from=builder --chmod=755 /usr/local/bin/ew /root/ew/ew
COPY --from=builder /ew/target/release/ew /root/ew/ew COPY --chmod=755 ./docker/start.sh /root/ew/start.sh
COPY ./docker/start.sh /root/ew/start.sh
RUN chmod +x /root/ew/start.sh
ENTRYPOINT ["/root/ew/start.sh"] ENTRYPOINT ["/root/ew/start.sh"]