make: use Docker named volumes for ~21x faster local linting
What changed, and why it matters
This commit is a build-system performance improvement, not a security fix. It changes how the project's linter Docker container stores its cache: on local developer machines it switches from slow folder-sharing (bind mounts) to faster internal Docker storage volumes, while in GitHub Actions CI it keeps using host paths so existing caching still works. There is no change to LND's runtime code, network behavior, or cryptographic handling.
No security action needed. Reviewers may optionally confirm that the CI bind-mount paths match the GOCACHE/GOMODCACHE values used in tools/Dockerfile and that the new clean-docker-volumes target is documented for developers.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The Makefile’s DOCKER_TOOLS variable is refactored to branch on the CI environment variable. In CI, it bind-mounts ~/.cache/go-build, ~/go/pkg/mod, and ~/.cache/golangci-lint into the lnd-tools container. Locally, it mounts named Docker volumes (lnd-go-build-cache, lnd-go-mod-cache, lnd-go-lint-cache) instead. A clean-docker-volumes target is added to remove those named volumes. The change is purely about I/O performance and cache persistence for linting.
Changed components
MakefileDocker-based linting workflowInspect captured patch +26 / −4
diff --git a/Makefile b/Makefile
index f12cdb3..c78e6e9 100644
--- a/Makefile
+++ b/Makefile
@@ -68,12 +68,28 @@ ifneq ($(workers),)
LINT_WORKERS = --concurrency=$(workers)
endif
+# Docker cache mounting strategy:
+# - CI (GitHub Actions): Use bind mounts to host paths that GA caches persist.
+# - Local: Use Docker named volumes (much faster on macOS/Windows due to
+# avoiding slow host-syncing overhead).
+# Paths inside container must match GOCACHE/GOMODCACHE in tools/Dockerfile.
+ifdef CI
+# CI mode: bind mount to host paths that GitHub Actions caches.
DOCKER_TOOLS = docker run \
--rm \
- -v $(shell bash -c "$(GOCC) env GOCACHE || (mkdir -p /tmp/go-cache; echo /tmp/go-cache)"):/tmp/build/.cache \
- -v $(shell bash -c "$(GOCC) env GOMODCACHE || (mkdir -p /tmp/go-modcache; echo /tmp/go-modcache)"):/tmp/build/.modcache \
- -v $(shell bash -c "mkdir -p /tmp/go-lint-cache; echo /tmp/go-lint-cache"):/root/.cache/golangci-lint \
+ -v $${HOME}/.cache/go-build:/tmp/build/.cache \
+ -v $${HOME}/go/pkg/mod:/tmp/build/.modcache \
+ -v $${HOME}/.cache/golangci-lint:/root/.cache/golangci-lint \
-v $$(pwd):/build lnd-tools
+else
+# Local mode: Docker named volumes for fast macOS/Windows performance.
+DOCKER_TOOLS = docker run \
+ --rm \
+ -v lnd-go-build-cache:/tmp/build/.cache \
+ -v lnd-go-mod-cache:/tmp/build/.modcache \
+ -v lnd-go-lint-cache:/root/.cache/golangci-lint \
+ -v $$(pwd):/build lnd-tools
+endif
GREEN := "\\033[0;32m"
NC := "\\033[0m"
@@ -472,6 +488,11 @@ clean-mobile:
$(RM) -r mobile/build
$(RM) mobile/*_generated.go
+#? clean-docker-volumes: Remove Docker cache volumes used for local development
+clean-docker-volumes:
+ @$(call print, "Removing Docker cache volumes.")
+ docker volume rm lnd-go-build-cache lnd-go-mod-cache lnd-go-lint-cache 2>/dev/null || true
+
.PHONY: all \
btcd \
default \
@@ -500,4 +521,5 @@ clean-mobile:
ios \
android \
mobile \
- clean
+ clean \
+ clean-docker-volumes
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.