Skip to content

Commit d6cec0b

Browse files
authored
Dockerfile with cargo artifacts caching (#8455)
When developing locally with kurtosis a typical dev workflow is: loop: - Build local lighthouse docker image - Run kurtosis - Observe bug - Fix code The docker build step would download and build all crates. Docker docs suggests an optimization to cache build artifacts, see https://docs.docker.com/build/cache/optimize/#use-cache-mounts I have tested and it's like building Lighthouse outside of a docker environment 🤤 The docker build time after changing one line in the top beacon_node crate is 50 seconds on my local machine ❤️ The release path is un-affected. Do you have worries this can affect the output of the release binaries? This is too good of an improvement to keep it in a separate Dockerfile. Co-Authored-By: dapplion <[email protected]>
1 parent bdfade8 commit d6cec0b

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
FROM rust:1.88.0-bullseye AS builder
22
RUN apt-get update && apt-get -y upgrade && apt-get install -y cmake libclang-dev
3-
COPY . lighthouse
43
ARG FEATURES
54
ARG PROFILE=release
65
ARG CARGO_USE_GIT_CLI=true
76
ENV FEATURES=$FEATURES
87
ENV PROFILE=$PROFILE
98
ENV CARGO_NET_GIT_FETCH_WITH_CLI=$CARGO_USE_GIT_CLI
10-
RUN cd lighthouse && make
9+
ENV CARGO_INCREMENTAL=1
10+
11+
WORKDIR /lighthouse
12+
COPY . .
13+
# Persist the registry and target file across builds. See: https://docs.docker.com/build/cache/optimize/#use-cache-mounts
14+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
15+
--mount=type=cache,target=/lighthouse/target \
16+
make
1117

1218
FROM ubuntu:22.04
1319
RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends \

Dockerfile.dev

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)