generated from maemreyo/rust-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (30 loc) · 974 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# STAGE 1: Generate a recipe file for dependencies
FROM rust:1.65 as planner
WORKDIR /app
RUN cargo install cargo-chef
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# STAGE 2: Build our dependencies
FROM rust:1.65 as cacher
WORKDIR /app
RUN cargo install cargo-chef
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# STAGE 3: Use the main official rust docker image as our build
FROM rust:1.65 as builder
# Copy the app into the docker image
COPY . /app
# Set the work directory
WORKDIR /app
# Copy dependencies
COPY --from=cacher /app/target target
COPY --from=cacher /usr/local/cargo /usr/local/cargo
# Build the app
RUN cargo build --release
# Use google distroless as runtime image
FROM gcr.io/distroless/cc-debian11
# Copy app from builder
COPY --from=builder /app/target/release/dev-works-logger /app/dev-works-logger
WORKDIR /app
# Start the application
ENTRYPOINT [ "./dev-works-logger" ]