-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
33 lines (29 loc) · 1.29 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
26
27
28
29
30
31
32
33
FROM --platform=$BUILDPLATFORM rust:1 as builder
WORKDIR /build
ARG TARGETPLATFORM
RUN \
set -eux ; \
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
apt-get --yes update && apt-get --yes install cmake musl-tools ; \
rustup target add x86_64-unknown-linux-musl ; \
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
apt-get --yes update && apt-get --yes install cmake musl-tools gcc-aarch64-linux-gnu ; \
rustup target add aarch64-unknown-linux-musl ; \
fi
COPY . .
RUN \
set -eux ; \
if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
export TARGET=x86_64-unknown-linux-musl ; \
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
export TARGET=aarch64-unknown-linux-musl ; \
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc ; \
export CC_aarch64_unknown_linux_musl=aarch64-linux-gnu-gcc ; \
export CXX_aarch64_unknown_linux_musl=aarch64-linux-gnu-g++ ; \
fi ; \
cargo build --release --target ${TARGET} && mkdir -p target/final/release/ && mv target/${TARGET}/release/texas target/final/release/texas ; \
file target/final/release/texas
FROM gcr.io/distroless/static-debian12:nonroot
WORKDIR /app
COPY --from=builder /build/target/final/release/texas /app/texas
CMD ["/app/texas"]