-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
34 lines (27 loc) · 1.09 KB
/
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
FROM lukemathwalker/cargo-chef as chef
# Run a cargo chef prepare for each workspace
FROM chef as planner
WORKDIR /common_workspace
COPY /common_workspace .
RUN cargo chef prepare --recipe-path recipe.json
WORKDIR /app_workspace
COPY /app_workspace .
RUN cargo chef prepare --recipe-path recipe.json
# Run a cargo cook for each workspace -
# shortcut unnecessary compilation with --bin xxx for the common_workspace
# as we're only need cargo chef to produce the empty crate for compilation from the app_workspace
FROM chef AS builder
WORKDIR /common_workspace
COPY --from=planner /common_workspace/recipe.json recipe.json
RUN cargo chef cook --release --bin xxx --recipe-path recipe.json || true
WORKDIR /app_workspace
COPY --from=planner /app_workspace/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Build application
COPY / /
RUN cargo build --release --bin app
# We do not need the Rust toolchain to run the binary!
FROM debian:buster-slim AS runtime
WORKDIR /app
COPY --from=builder /app_workspace/target/release/app /usr/local/bin
ENTRYPOINT ["/usr/local/bin/app"]