mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-02 16:21:42 +00:00
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 <35266934+dapplion@users.noreply.github.com>
This commit is contained in:
10
Dockerfile
10
Dockerfile
@@ -1,13 +1,19 @@
|
||||
FROM rust:1.88.0-bullseye AS builder
|
||||
RUN apt-get update && apt-get -y upgrade && apt-get install -y cmake libclang-dev
|
||||
COPY . lighthouse
|
||||
ARG FEATURES
|
||||
ARG PROFILE=release
|
||||
ARG CARGO_USE_GIT_CLI=true
|
||||
ENV FEATURES=$FEATURES
|
||||
ENV PROFILE=$PROFILE
|
||||
ENV CARGO_NET_GIT_FETCH_WITH_CLI=$CARGO_USE_GIT_CLI
|
||||
RUN cd lighthouse && make
|
||||
ENV CARGO_INCREMENTAL=1
|
||||
|
||||
WORKDIR /lighthouse
|
||||
COPY . .
|
||||
# Persist the registry and target file across builds. See: https://docs.docker.com/build/cache/optimize/#use-cache-mounts
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/lighthouse/target \
|
||||
make
|
||||
|
||||
FROM ubuntu:22.04
|
||||
RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends \
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
FROM rust:1.88.0-bullseye AS builder
|
||||
RUN apt-get update && apt-get -y upgrade && apt-get install -y cmake libclang-dev
|
||||
WORKDIR /lighthouse
|
||||
|
||||
ARG FEATURES
|
||||
ARG PROFILE=release
|
||||
ARG CARGO_USE_GIT_CLI=true
|
||||
ENV FEATURES=$FEATURES
|
||||
ENV PROFILE=$PROFILE
|
||||
ENV CARGO_NET_GIT_FETCH_WITH_CLI=$CARGO_USE_GIT_CLI
|
||||
ENV CARGO_INCREMENTAL=1
|
||||
|
||||
COPY . .
|
||||
# Persist the registry and target file across builds. See: https://docs.docker.com/build/cache/optimize/#use-cache-mounts
|
||||
RUN --mount=type=cache,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,target=/lighthouse/target \
|
||||
make
|
||||
|
||||
FROM ubuntu:22.04
|
||||
RUN apt-get update && apt-get -y upgrade && apt-get install -y --no-install-recommends \
|
||||
libssl-dev \
|
||||
ca-certificates \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
COPY --from=builder /usr/local/cargo/bin/lighthouse /usr/local/bin/lighthouse
|
||||
Reference in New Issue
Block a user