-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
15 additions
and
6 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 |
---|---|---|
@@ -1,19 +1,28 @@ | ||
FROM rust AS builder | ||
FROM rust:slim AS builder | ||
|
||
WORKDIR /src/builder | ||
|
||
ARG TARGETARCH | ||
RUN if [ $TARGETARCH = "amd64" ]; then \ | ||
echo "x86_64" > /tmp/arch; \ | ||
elif [ $TARGETARCH = "arm64" ]; then \ | ||
echo "aarch64" > /tmp/arch; \ | ||
else \ | ||
echo "Unsupported platform"; \ | ||
exit 1; \ | ||
fi | ||
|
||
RUN apt-get update && apt-get install -y musl-tools | ||
RUN rustup target add aarch64-unknown-linux-musl | ||
RUN rustup target add $(cat /tmp/arch)-unknown-linux-musl | ||
|
||
COPY . . | ||
RUN --mount=type=cache,target=/src/builder/target/ cargo build --target=aarch64-unknown-linux-musl --release && \ | ||
cp target/aarch64-unknown-linux-musl/release/expander /tmp/expander | ||
RUN --mount=type=cache,target=/src/builder/target/ cargo build --target=$(cat /tmp/arch)-unknown-linux-musl --release && \ | ||
cp target/$(cat /tmp/arch)-unknown-linux-musl/release/expander /tmp/expander | ||
|
||
FROM alpine | ||
FROM scratch | ||
|
||
WORKDIR /src/app | ||
|
||
RUN apk add ca-certificates | ||
COPY --from=builder /tmp/expander . | ||
|
||
CMD ["./expander"] |