diff --git a/dev.Dockerfile b/dev.Dockerfile index 82709627a..d8eaa6824 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -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" diff --git a/docs/release-notes/release-notes-0.22.0.md b/docs/release-notes/release-notes-0.22.0.md index 75454ee1a..2f7f0ca1b 100644 --- a/docs/release-notes/release-notes-0.22.0.md +++ b/docs/release-notes/release-notes-0.22.0.md @@ -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