Merge pull request #10903 from ZZiigguurraatt/cache_golang
Some checks are pending
CI / Static Checks (push) Waiting to run
CI / Check commits (push) Waiting to run
CI / Lint code (push) Waiting to run
CI / Cross compilation (push) Waiting to run
CI / Cross compilation-1 (push) Waiting to run
CI / Cross compilation-2 (push) Waiting to run
CI / Run unit tests (push) Waiting to run
CI / Run unit tests-1 (push) Waiting to run
CI / Run unit tests-2 (push) Waiting to run
CI / Run unit tests-3 (push) Waiting to run
CI / Run unit tests-4 (push) Waiting to run
CI / Run unit tests-5 (push) Waiting to run
CI / Run unit tests-6 (push) Waiting to run
CI / Run unit tests-7 (push) Waiting to run
CI / Run unit tests-8 (push) Waiting to run
CI / Run unit tests-9 (push) Waiting to run
CI / Run basic itests (push) Waiting to run
CI / Run basic itests-1 (push) Waiting to run
CI / Run basic itests-2 (push) Waiting to run
CI / Run basic itests-3 (push) Waiting to run
CI / Run basic itests-4 (push) Waiting to run
CI / Run itests (push) Waiting to run
CI / Run itests-1 (push) Waiting to run
CI / Run itests-2 (push) Waiting to run
CI / Run itests-3 (push) Waiting to run
CI / Run itests-4 (push) Waiting to run
CI / Run itests-5 (push) Waiting to run
CI / Run itests-6 (push) Waiting to run
CI / Run itests-7 (push) Waiting to run
CI / Run windows itest (push) Waiting to run
CI / Run macOS itest (push) Waiting to run
CI / Check pinned dependencies (push) Waiting to run
CI / Check pinned dependencies-1 (push) Waiting to run
CI / Check release notes updated (push) Waiting to run
CI / Backwards compatibility test (push) Waiting to run
CI / Cache Cleanup (push) Waiting to run
CI / Send coverage report (push) Blocked by required conditions

dev.Dockerfile: use cache mounts to speed up rebuilding
This commit is contained in:
Yong 2026-06-17 21:31:12 +08:00 committed by GitHub
commit f771e14191
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -18,7 +18,13 @@ RUN apk add --no-cache --update alpine-sdk \
COPY . /go/src/github.com/lightningnetwork/lnd
# Install/build lnd.
RUN cd /go/src/github.com/lightningnetwork/lnd \
# Note: When using `docker build`, setting the environmental variable
# `DOCKER_BUILDKIT=1` is required to enable
# [BuildKit](https://docs.docker.com/build/buildkit)
# so that the cache mounts can be used.
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
cd /go/src/github.com/lightningnetwork/lnd \
&& make \
&& make install-all tags="signrpc walletrpc chainrpc invoicesrpc peersrpc kvdb_sqlite"

View file

@ -100,6 +100,17 @@
## Tooling and Documentation
* [`dev.Dockerfile` now uses](https://github.com/lightningnetwork/lnd/pull/10903)
[cache mounts](https://docs.docker.com/build/cache/optimize/#use-cache-mounts)
to cache the `GOMODCACHE` and `GOCACHE` directories so that dependencies don't
need to be re-downloaded and re-built every time the image is re-created.
As a result of this change, `dev.Dockerfile` now requires
[BuildKit](https://docs.docker.com/build/buildkit) to build. When using
`docker build`, this can be enabled by setting the environmental variable
`DOCKER_BUILDKIT=1`. BuildKit also does not unnecessarily rebuild images when
the build context is a remote git repository because COPY layers are more
smartly compared to cache.
# Contributors (Alphabetical Order)
* bitromortac