1
1
# init final base
2
- FROM ubuntu:22.04 AS final_base
2
+ FROM ubuntu AS final_base
3
3
# These steps copy over the epoch accumulators repo for the bridge to use
4
4
# This data is too large to be kept inside trin-source code
5
5
# It must be downloaded separately and moved to the correct location
@@ -9,54 +9,36 @@ FROM ubuntu:22.04 AS final_base
9
9
RUN mkdir /portal-accumulators
10
10
COPY ./portal-accumulators /portal-accumulators
11
11
12
- # select build image
13
- FROM rust:1.81.0 AS builder
12
+ FROM lukemathwalker/cargo-chef:latest-rust-1 AS chef
13
+ WORKDIR /app
14
14
15
- # create a new empty shell project
16
- RUN USER=root cargo new --bin trin
17
- WORKDIR /trin
15
+ RUN apt-get update && apt-get install clang -y
18
16
19
- # Docker build command *SHOULD* include --build-arg GIT_HASH=...
20
- # eg. --build-arg GIT_HASH=$(git rev-parse HEAD)
21
- ARG GIT_HASH=unknown
22
- ENV GIT_HASH=$GIT_HASH
17
+ FROM chef AS planner
18
+ COPY . .
19
+ RUN cargo chef prepare --recipe-path recipe.json
23
20
24
- RUN apt-get update && apt-get install clang -y
21
+ FROM chef AS builder
22
+ COPY --from=planner /app/recipe.json recipe.json
25
23
26
- # copy over manifests and source to build image
27
- COPY ./Cargo.lock ./Cargo.lock
28
- COPY ./Cargo.toml ./Cargo.toml
29
- COPY ./e2store ./e2store
30
- COPY ./ethportal-api ./ethportal-api
31
- COPY ./ethportal-peertest ./ethportal-peertest
32
- COPY ./light-client ./light-client
33
- COPY ./portalnet ./portalnet
34
- COPY ./portal-bridge ./portal-bridge
35
- COPY ./rpc ./rpc
36
- COPY ./src ./src
37
- COPY ./trin-beacon ./trin-beacon
38
- COPY ./trin-evm ./trin-evm
39
- COPY ./trin-execution ./trin-execution
40
- COPY ./trin-history ./trin-history
41
- COPY ./trin-metrics ./trin-metrics
42
- COPY ./trin-state ./trin-state
43
- COPY ./trin-storage ./trin-storage
44
- COPY ./trin-utils ./trin-utils
45
- COPY ./trin-validation ./trin-validation
46
- COPY ./utp-testing ./utp-testing
24
+ # Build dependencies - this is the caching Docker layer!
25
+ RUN cargo chef cook --release --recipe-path recipe.json
47
26
48
- # build for release
49
- RUN cargo build -p trin -p portal-bridge --release
27
+ # Build application
28
+ # Copy over all project folders specified in the .dockerignore
29
+ COPY . .
30
+ RUN cargo build --release --locked -p trin -p portal-bridge
50
31
51
- # final base
32
+ # We do not need the Rust toolchain to run the binary!
52
33
FROM final_base
34
+ WORKDIR /app
53
35
54
36
# copy build artifacts from build stage
55
- COPY --from=builder /trin /target/release/trin /usr/bin/
56
- COPY --from=builder /trin /trin-execution/resources /resources
57
- COPY --from=builder /trin /target/release/portal-bridge /usr/bin/
58
- COPY --from=builder /trin /target/release/sample_range /usr/bin/
59
- COPY --from=builder /trin /target/release/poll_latest /usr/bin/
37
+ COPY --from=builder /app /target/release/trin /usr/bin/
38
+ COPY --from=builder /app /trin-execution/resources /resources
39
+ COPY --from=builder /app /target/release/portal-bridge /usr/bin/
40
+ COPY --from=builder /app /target/release/sample_range /usr/bin/
41
+ COPY --from=builder /app /target/release/poll_latest /usr/bin/
60
42
61
43
RUN apt-get update && apt-get install libcurl4 -y
62
44
0 commit comments