-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
46 lines (33 loc) · 1.07 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
35
36
37
38
39
40
41
42
43
44
45
46
# this should match the Rust version in rust-toolchain.yaml and the
FROM rust:1.82.0 AS chef
WORKDIR app
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends --assume-yes \
lld libssl-dev ssh git pkg-config
ENV CARGO_HOME=/app/.cargo
ENV PATH="$PATH:$CARGO_HOME/bin"
RUN cargo install cargo-chef
COPY rust-toolchain.toml .
RUN rustup show
###
# Plan recipe
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
###
# Build recipe
FROM chef AS build
COPY --from=planner /app/recipe.json recipe.json
# build dependencies to produce a cached layer
RUN cargo chef cook --release --all-targets --recipe-path recipe.json
RUN cargo chef cook --all-targets --recipe-path recipe.json
# copy the source after building dependencies to allow caching
COPY . .
# Build the app
RUN cargo build --release --all-targets
###
# Ship the app in an image with very little else
FROM debian:bookworm-slim as ndc-reference
COPY --from=build /app/target/release/ndc-reference /usr/bin/ndc-reference
ENTRYPOINT ["ndc-reference"]