Skip to content

Commit 4bd8866

Browse files
committed
Configure cross-compile in dockerfile
1 parent ef6379b commit 4bd8866

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Dockerfile

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
FROM rust:latest AS build
1+
FROM --platform=$BUILDPLATFORM rust:latest AS build
2+
3+
ARG TARGETPLATFORM
4+
ARG TARGETARCH
25

36
WORKDIR /app
47

58
RUN \
69
DEBIAN_FRONTEND=noninteractive \
7-
apt-get update &&\
8-
apt-get -y install ca-certificates tzdata
10+
apt-get update && \
11+
apt-get -y install ca-certificates tzdata && \
12+
if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then apt install -y g++-aarch64-linux-gnu; fi;
13+
14+
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
915

1016
COPY . .
1117

12-
RUN \
13-
CARGO_NET_GIT_FETCH_WITH_CLI=true \
14-
cargo build --release
18+
RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
19+
rustup target add aarch64-unknown-linux-gnu && \
20+
cargo build --target aarch64-unknown-linux-gnu --release; \
21+
else \
22+
cargo build --release; \
23+
fi
1524

1625
# https://hub.docker.com/r/bitnami/minideb
1726
FROM bitnami/minideb:latest AS final

0 commit comments

Comments
 (0)