|
6 | 6 |
|
7 | 7 | ################################################################################ |
8 | 8 | # Base image as the foundation for the other build stages in this file. |
9 | | -FROM rust:slim AS chef |
10 | | - |
11 | | -# Set the environment variables for the build. |
12 | | -ENV CARGO_UNSTABLE_SPARSE_REGISTRY=true |
13 | | -ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse |
14 | | - |
15 | | -# We only pay the installation cost once, |
16 | | -# it will be cached from the second build onwards |
17 | | -RUN rustup default stable |
18 | | -RUN rustup component add cargo rust-std rustc |
19 | | -RUN cargo install cargo-chef |
20 | | - |
| 9 | +FROM lukemathwalker/cargo-chef:latest-rust-1-slim-bookworm AS chef |
21 | 10 | WORKDIR /app |
22 | 11 |
|
23 | 12 | ################################################################################ |
@@ -49,11 +38,20 @@ RUN cargo build --release --bin stackclass-server |
49 | 38 | # the smallest image possible. This often means using a different and smaller |
50 | 39 | # image than the one used for building the application, but for illustrative |
51 | 40 | # purposes the "base" image is used here. |
52 | | -FROM gcr.io/distroless/cc-debian12:nonroot AS runtime |
| 41 | +FROM debian:bookworm-slim AS runtime |
| 42 | +WORKDIR /app |
| 43 | + |
| 44 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 45 | + ca-certificates \ |
| 46 | + && apt-get clean \ |
| 47 | + && rm -rf /var/lib/apt/lists/* |
| 48 | + |
| 49 | +RUN addgroup --system --gid 1001 axum |
| 50 | +RUN adduser --system --uid 1001 axum |
| 51 | +USER axum |
53 | 52 |
|
54 | 53 | # Copy the executable from the "building" stage. |
55 | 54 | COPY --from=builder \ |
56 | | - --chown=nonroot:nonroot \ |
57 | 55 | /app/target/release/stackclass-server \ |
58 | 56 | /usr/local/bin/ |
59 | 57 |
|
|
0 commit comments