2023-05-13 18:48:23 +02:00
|
|
|
FROM rust:1.69.0 AS builder
|
2022-12-30 00:55:21 +01:00
|
|
|
WORKDIR /usr/src/rust_application
|
2022-04-23 18:41:14 +02:00
|
|
|
|
2022-12-30 00:55:21 +01:00
|
|
|
# Cache dependencies
|
|
|
|
RUN cargo init --bin ./
|
|
|
|
COPY ./Cargo.* ./
|
|
|
|
RUN cargo build --release && rm --recursive --force ./src ./target/release/deps/rust_application*
|
2022-04-23 18:41:14 +02:00
|
|
|
|
2022-12-30 00:55:21 +01:00
|
|
|
# Build application
|
|
|
|
COPY ./ ./
|
|
|
|
RUN cargo build --release
|
|
|
|
|
|
|
|
FROM gcr.io/distroless/cc-debian11:latest AS runner
|
|
|
|
WORKDIR /usr/src/rust_application
|
|
|
|
COPY --from=builder /usr/src/rust_application/target/release/rust_application ./
|
|
|
|
CMD ["./rust_application"]
|