Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
88 lines (75 loc) · 3.12 KB
/
Copy pathDockerfile
File metadata and controls
88 lines (75 loc) · 3.12 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
FROM rust:1.95 AS chef
WORKDIR /usr/src/app
ARG MALACHITE_GIT_REPO_URL=https://github.com/farcasterxyz/malachite.git
ENV MALACHITE_GIT_REPO_URL=$MALACHITE_GIT_REPO_URL
ARG MALACHITE_GIT_REF=58730933edc170a395e6a905d791fac4666da192
ENV RUST_BACKTRACE=1
RUN <<EOF
set -eu
apt-get -o Acquire::Retries=0 update && apt-get -o Acquire::Retries=0 install -y --only-upgrade apt && \
apt-get -o Acquire::Retries=0 install -y libclang-dev git libjemalloc-dev llvm-dev make protobuf-compiler libssl-dev openssh-client cmake || exit 1
cargo install cargo-chef --locked
cd ..
git clone $MALACHITE_GIT_REPO_URL
cd malachite
git checkout $MALACHITE_GIT_REF
EOF
# Analyze dependencies and create a build recipe
FROM chef AS planner
COPY Cargo.lock Cargo.toml ./
COPY proto ./proto
COPY cli ./cli
COPY src ./src
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder
# Build ONLY dependencies (cached until Cargo.lock/Cargo.toml change)
COPY --from=planner /usr/src/app/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json
# Build the actual source (only this layer invalidates on src/ changes)
COPY Cargo.lock Cargo.toml ./
COPY proto ./proto
COPY cli ./cli
COPY src ./src
ENV RUST_BACKTRACE=full
# `--workspace --bins` picks up bins from `cli/` (the `fc` CLI) in addition to the snapchain
# package's bins. Without `--workspace`, cargo only builds bins from the root package.
RUN cargo build --release --workspace --bins
## Pre-generate some configurations we can use
# TOOD: consider doing something different here
RUN target/release/setup_local_testnet --docker --admin-rpc-auth dev:dev
#################################################################################
FROM ubuntu:26.04
# Easier debugging within container
ARG GRPCURL_VERSION=1.9.4
ARG TARGETOS
ARG TARGETARCH
# ca-certificates is installed explicitly (not just as a curl recommendation) because
# tonic's `tls-native-roots` reads the system trust store at runtime.
RUN <<EOF
set -eu
echo 'Acquire::Retries "0";' > /etc/apt/apt.conf.d/99-cve-2026-109518 && \
apt-get update && apt-get install -y --no-install-recommends ca-certificates curl || exit 1
curl -fL https://github.com/fullstorydev/grpcurl/releases/download/v${GRPCURL_VERSION}/grpcurl_${GRPCURL_VERSION}_${TARGETOS}_${TARGETARCH}.deb > grpcurl.deb
dpkg -i grpcurl.deb
rm grpcurl.deb
apt-get remove -y curl
apt-get autoremove -y
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF
WORKDIR /app
COPY --from=builder /usr/src/app/proto/definitions /app/proto
COPY --from=builder /usr/src/app/nodes /app/nodes
COPY --from=builder \
/usr/src/app/target/release/snapchain \
/usr/src/app/target/release/follow_blocks \
/usr/src/app/target/release/setup_local_testnet \
/usr/src/app/target/release/submit_message \
/usr/src/app/target/release/perftest \
/usr/src/app/target/release/fc \
/app/
COPY scripts/apply-onchain-config.sh scripts/onchain-config-watch.sh /app/
ENV RUSTFLAGS="-Awarnings"
# Compose files override both entrypoint and command; this default only covers
# a bare `docker run` (the previous `--id 1` was not a valid flag and exited 1).
CMD ["./snapchain", "--config-path", "config.toml"]