-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathDockerfile
More file actions
79 lines (66 loc) · 2.43 KB
/
Copy pathDockerfile
File metadata and controls
79 lines (66 loc) · 2.43 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
FROM rust:1.96 AS chef
WORKDIR /usr/src/app
ARG MALACHITE_GIT_REPO_URL=https://github.com/informalsystems/malachite.git
ENV MALACHITE_GIT_REPO_URL=$MALACHITE_GIT_REPO_URL
ARG MALACHITE_GIT_REF=13bca14cd209d985c3adf101a02924acde8723a5
ENV RUST_BACKTRACE=1
RUN <<EOF
set -eu
apt-get update && apt-get install -y libclang-dev git libjemalloc-dev llvm-dev make protobuf-compiler libssl-dev openssh-client cmake
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:24.04
# Easier debugging within container
ARG GRPCURL_VERSION=1.9.1
ARG TARGETOS
ARG TARGETARCH
RUN <<EOF
set -eu
apt-get update && apt-get install -y curl
curl -L 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 clean -y
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/
ENV RUSTFLAGS="-Awarnings"
CMD ["./snapchain", "--id", "1"]