-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
25 lines (23 loc) · 1.01 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
FROM --platform=$BUILDPLATFORM rust:1.83.0-alpine3.20 AS builder
ENV PKGCONFIG_SYSROOTDIR=/
RUN apk add --no-cache musl-dev libressl-dev perl build-base zig
RUN cargo install --locked cargo-zigbuild
RUN rustup target add x86_64-unknown-linux-musl aarch64-unknown-linux-musl
WORKDIR /app
COPY Cargo.toml Cargo.lock .
RUN mkdir src \
&& echo "fn main() {}" > src/main.rs \
&& cargo fetch \
&& cargo zigbuild --release --target x86_64-unknown-linux-musl --target aarch64-unknown-linux-musl \
&& rm src/main.rs
COPY src ./src
COPY README.md .
RUN cargo zigbuild --release --target x86_64-unknown-linux-musl --target aarch64-unknown-linux-musl
FROM --platform=$BUILDPLATFORM scratch AS binary
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/sandhole /sandhole-linux-amd64
COPY --from=builder /app/target/aarch64-unknown-linux-musl/release/sandhole /sandhole-linux-arm64
FROM scratch AS runner
ARG TARGETOS
ARG TARGETARCH
COPY --from=binary /sandhole-${TARGETOS}-${TARGETARCH} /sandhole
ENTRYPOINT [ "/sandhole" ]