-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (35 loc) · 1.38 KB
/
Dockerfile
File metadata and controls
48 lines (35 loc) · 1.38 KB
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
47
48
ARG EXE_NAME=public-ingest
FROM rust:1.90.0-slim-bookworm AS chef
RUN apt-get update \
&& apt-get install -y --no-install-recommends protobuf-compiler libprotobuf-dev sccache ca-certificates gcc libssl-dev pkg-config cmake build-essential curl
RUN cargo install --locked cargo-chef
ENV RUSTC_WRAPPER=sccache SCCACHE_DIR=/sccache
WORKDIR /app
FROM chef AS planner
ARG EXE_NAME
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
ARG EXE_NAME
WORKDIR /app
COPY --from=planner /app/recipe.json recipe.json
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
cargo build --release --bin ${EXE_NAME}
# We do not need the Rust toolchain to run the binary!
FROM debian:bookworm-slim AS runtime
ARG EXE_NAME
ENV exe_name=$EXE_NAME
ENV RUST_LOG=debug
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates libssl-dev openssl libc6 curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /app/target/release/${EXE_NAME} /usr/local/bin
CMD "/usr/local/bin/${exe_name}"