Skip to content

Commit a3d749a

Browse files
authored
perf: improve Dockerfile caching (#1053)
1 parent 3342290 commit a3d749a

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

Dockerfile

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,37 @@ RUN apt-get update && apt-get install -y cmake protobuf-compiler
3333
# Install protobuf for elixir
3434
RUN mix escript.install --force hex protobuf
3535

36+
# Download openapi spec
37+
COPY Makefile .oapi_version /consensus/
38+
RUN make download-beacon-node-oapi
39+
3640
# Install rust
3741
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
3842

3943
ENV PATH="${PATH}:/root/.cargo/bin:/root/.mix/escripts"
4044

45+
# Precompile rust crates. Rustler stores targets under _build
46+
COPY ./native /consensus/native
47+
RUN cd /consensus/native/bls_nif && cargo build --release \
48+
--target-dir="/consensus/_build/prod/lib/lambda_ethereum_consensus/native/bls_nif"
49+
RUN cd /consensus/native/kzg_nif && cargo build --release \
50+
--target-dir="/consensus/_build/prod/lib/lambda_ethereum_consensus/native/kzg_nif"
51+
RUN cd /consensus/native/snappy_nif && cargo build --release \
52+
--target-dir="/consensus/_build/prod/lib/lambda_ethereum_consensus/native/snappy_nif"
53+
RUN cd /consensus/native/ssz_nif && cargo build --release \
54+
--target-dir="/consensus/_build/prod/lib/lambda_ethereum_consensus/native/ssz_nif"
55+
56+
# Precompile elixir dependencies
57+
COPY mix.exs mix.lock .fork_version ./
58+
COPY ./config/config.exs /consensus/config/config.exs
59+
RUN mix deps.get
60+
RUN mix deps.compile
61+
4162
COPY . .
4263
COPY --from=libp2p_builder /libp2p_port/libp2p_port /consensus/priv/native/libp2p_port
4364

4465
RUN protoc --elixir_out=./lib proto/libp2p.proto
4566

46-
RUN make download-beacon-node-oapi
47-
48-
RUN mix deps.get
4967
RUN mix compile
5068

5169
ENTRYPOINT [ "iex", "-S", "mix", "run", "--"]

0 commit comments

Comments
 (0)