Skip to content

Commit

Permalink
Update Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
tuna2134 authored Feb 3, 2024
1 parent e84ab92 commit ac8af1b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Dockerfile
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"]

0 comments on commit ac8af1b

Please sign in to comment.