-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
64 lines (50 loc) · 1.6 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#
# Base container (with sccache and cargo-chef)
#
# - https://github.com/mozilla/sccache
# - https://github.com/LukeMathWalker/cargo-chef
#
# Based on https://depot.dev/blog/rust-dockerfile-best-practices
#
FROM rust:1.82 AS base
ARG FEATURES
RUN cargo install sccache --version ^0.9
RUN cargo install cargo-chef --version ^0.1
RUN apt-get update \
&& apt-get install -y clang libclang-dev
ENV CARGO_HOME=/usr/local/cargo
ENV RUSTC_WRAPPER=sccache
ENV SCCACHE_DIR=/sccache
#
# Planner container (running "cargo chef prepare")
#
FROM base AS planner
WORKDIR /app
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 chef prepare --recipe-path recipe.json
#
# Builder container (running "cargo chef cook" and "cargo build --release")
#
FROM base AS builder
WORKDIR /app
# Default binary filename
ARG ROLLUP_BOOST_BIN="rollup-boost"
COPY --from=planner /app/recipe.json recipe.json
RUN --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 --features="$FEATURES" --package=${ROLLUP_BOOST_BIN}
#
# Runtime container
#
FROM gcr.io/distroless/cc-debian12
WORKDIR /app
ARG ROLLUP_BOOST_BIN="rollup-boost"
COPY --from=builder /app/target/release/${ROLLUP_BOOST_BIN} /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/rollup-boost"]