2025-03-08 00:53:11 +01:00
|
|
|
# syntax=docker/dockerfile:1
|
2026-05-10 10:43:29 +02:00
|
|
|
FROM rust:alpine AS chef
|
|
|
|
|
RUN apk add --no-cache musl-dev lld g++ make perl openssl-dev openssl-libs-static protobuf-dev
|
|
|
|
|
RUN cargo install cargo-chef
|
2025-03-05 23:20:11 +01:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-05-10 10:43:29 +02:00
|
|
|
FROM chef AS planner
|
2025-03-05 23:20:11 +01:00
|
|
|
COPY . .
|
2026-05-10 10:43:29 +02:00
|
|
|
RUN cargo chef prepare --recipe-path recipe.json
|
2025-03-05 23:20:11 +01:00
|
|
|
|
2026-05-10 10:43:29 +02:00
|
|
|
FROM chef AS builder
|
|
|
|
|
COPY --from=planner /app/recipe.json recipe.json
|
2025-03-05 23:20:11 +01:00
|
|
|
|
2026-04-28 20:47:20 +02:00
|
|
|
ENV SQLX_OFFLINE=true
|
2026-05-10 10:43:29 +02:00
|
|
|
ENV RUSTFLAGS="-C target-feature=+aes,+sse -C relocation-model=static -C linker=ld.lld"
|
2025-03-06 11:36:21 +00:00
|
|
|
|
2026-05-10 10:43:29 +02:00
|
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
|
|
|
--mount=type=cache,target=/app/target \
|
|
|
|
|
cargo chef cook --profile prod --recipe-path recipe.json --target x86_64-unknown-linux-musl
|
2025-03-05 23:20:11 +01:00
|
|
|
|
2026-05-10 10:43:29 +02:00
|
|
|
COPY . .
|
|
|
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
|
|
|
|
--mount=type=cache,target=/app/target \
|
|
|
|
|
cargo build --profile prod --target x86_64-unknown-linux-musl && \
|
|
|
|
|
mkdir -p /app/dist && \
|
|
|
|
|
cp /app/target/x86_64-unknown-linux-musl/prod/account /app/dist/
|
2025-03-05 23:20:11 +01:00
|
|
|
|
2026-05-10 10:43:29 +02:00
|
|
|
FROM scratch AS final
|
|
|
|
|
WORKDIR /
|
|
|
|
|
COPY --from=builder /app/dist/account /account
|
2025-11-04 22:23:24 +01:00
|
|
|
COPY --from=builder /app/res /res
|
2026-05-10 10:43:29 +02:00
|
|
|
ENTRYPOINT ["/account"]
|