From 7c64571531c930417c7fe3047f367e242099344d Mon Sep 17 00:00:00 2001 From: Veirt Date: Fri, 2 Aug 2024 01:51:55 +0800 Subject: [PATCH] build: setup multiplatform build --- .github/workflows/build.yml | 1 + Dockerfile | 14 +++++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0efa6ed..8124b16 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,6 +53,7 @@ jobs: context: . push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} + targets: linux/amd64,linux/arm64 labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index d582b45..d685e57 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,18 @@ -FROM rust:1.80 AS build - -WORKDIR /usr/src -RUN apt-get update -y && \ - apt-get install -y --no-install-recommends musl-tools && \ - rustup target add x86_64-unknown-linux-musl +FROM --platform=$BUILDPLATFORM rust:1.80-alpine AS build +RUN apk add musl-dev --no-cache +WORKDIR /usr/src RUN USER=root cargo new --bin vesta WORKDIR /usr/src/vesta COPY Cargo.toml Cargo.lock ./ COPY src ./src -RUN cargo install --target x86_64-unknown-linux-musl --path . - +RUN cargo build --release FROM scratch WORKDIR /app COPY ./static static -COPY --from=build /usr/src/vesta/target/x86_64-unknown-linux-musl/release/vesta . +COPY --from=build /usr/src/vesta/target/release/vesta /app/vesta CMD ["/app/vesta"]