forked from flashbots/rbuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
72 lines (56 loc) · 1.75 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
65
66
67
68
69
70
71
72
#
# 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.79 as base
RUN cargo install sccache --version ^0.8
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 ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY ./.git ./.git
COPY ./crates/ ./crates/
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
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 ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY ./.git ./.git
COPY ./crates/ ./crates/
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
#
# Runtime container
#
FROM gcr.io/distroless/cc-debian12
WORKDIR /app
# RUN apk add libssl3 ca-certificates
# RUN apt-get update \
# && apt-get install -y libssl3 ca-certificates \
# && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/rbuilder /app/rbuilder
ENTRYPOINT ["/app/rbuilder"]