-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for
linux/arm64
image
- Loading branch information
Showing
2 changed files
with
18 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ jobs: | |
strategy: | ||
matrix: | ||
platform: | ||
- linux/arm64 | ||
- linux/amd64 | ||
|
||
steps: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
FROM --platform=amd64 rust:1.72-alpine as builder | ||
FROM rust:1.72-slim as builder | ||
ARG TARGETPLATFORM | ||
WORKDIR /build | ||
|
||
# RUN apt-get update && apt-get install -y build-essential musl-dev musl-tools gcc-x86-64-linux-gnu && apt-get clean && rm -rf /var/lib/apt/lists/* | ||
RUN apk update && apk upgrade && apk add --no-cache musl-dev | ||
RUN rustup target add x86_64-unknown-linux-musl | ||
RUN set -ex; \ | ||
case "$TARGETPLATFORM" in \ | ||
"linux/amd64") target='x86_64-unknown-linux-musl' ;; \ | ||
"linux/arm64") target='aarch64-unknown-linux-musl' ;; \ | ||
*) echo >&2 "error: unsupported $TARGETPLATFORM architecture"; exit 1 ;; \ | ||
esac; \ | ||
echo "$target" > /tmp/target-spec | ||
|
||
RUN apt-get update && apt-get install -y build-essential musl-dev musl-tools && apt-get clean && rm -rf /var/lib/apt/lists/* | ||
# RUN apk update && apk upgrade && apk add --no-cache musl-dev | ||
RUN rustup target add "$(cat /tmp/target-spec)" | ||
|
||
ENV CARGO_BUILD_RUSTFLAGS="-C target-feature=+crt-static" | ||
|
||
COPY . . | ||
RUN cargo fetch --target x86_64-unknown-linux-musl --locked | ||
RUN cargo build --target x86_64-unknown-linux-musl --release --locked | ||
RUN cargo fetch --target "$(cat /tmp/target-spec)" --locked | ||
RUN cargo build --target "$(cat /tmp/target-spec)" --release --locked | ||
RUN cp "/build/target/$(cat /tmp/target-spec)/release/valfisk" /build/valfisk | ||
|
||
FROM gcr.io/distroless/static:latest | ||
COPY --from=builder /build/target/x86_64-unknown-linux-musl/release/valfisk /valfisk | ||
|
||
COPY --from=builder /build/valfisk /valfisk | ||
CMD ["/valfisk"] |