Last active
November 30, 2022 22:28
-
-
Save lgirault/7cacac0d4509bfb7df0cd003f15bf3bd to your computer and use it in GitHub Desktop.
zero2prod on arm
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
FROM rust:latest as chef | |
WORKDIR /app | |
RUN apt update && apt upgrade -y | |
RUN apt install -y g++-arm-linux-gnueabihf libc6-dev-armhf-cross | |
RUN rustup target add armv7-unknown-linux-gnueabihf | |
RUN cargo install cargo-chef | |
FROM chef as planner | |
COPY . . | |
RUN cargo chef prepare --recipe-path recipe.json | |
FROM chef as builder | |
COPY --from=planner /app/recipe.json recipe.json | |
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc CC_armv7_unknown_Linux_gnueabihf=arm-linux-gnueabihf-gcc CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ | |
RUN cargo chef cook --release --target armv7-unknown-linux-gnueabihf --recipe-path recipe.json | |
COPY . . | |
ENV SQLX_OFFLINE true | |
RUN cargo build --target armv7-unknown-linux-gnueabihf --release --bin zero2prod | |
# Runtime stage | |
FROM --platform=linux/arm/v7 debian:bullseye-slim AS runtime | |
WORKDIR /app | |
RUN apt-get update -y \ | |
&& apt-get install -y --no-install-recommends openssl ca-certificates \ | |
# Clean up | |
&& apt-get autoremove -y \ | |
&& apt-get clean -y \ | |
&& rm -rf /var/lib/apt/lists/* | |
COPY --from=builder /app/target/armv7-unknown-linux-gnueabihf/release/zero2prod zero2prod | |
COPY configuration configuration | |
ENV APP_ENVIRONMENT production | |
ENTRYPOINT ["./zero2prod"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to run
docker run --privileged --rm tonistiigi/binfmt --install all
before the build, as per doc : https://docs.docker.com/build/building/multi-platform/
The runtime stage running on linux/arm/v7 platform