Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Comment on lines +88 to +90

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

With the introduction of named Docker volumes for local development, it would be beneficial to also add a make target to clean them up. These volumes will persist on the user's machine and can grow in size over time. A developer might want to clear them to start from a clean slate or to free up disk space.

You could add a new target like this:

.PHONY: clean-docker-volumes
clean-docker-volumes:
	@$(call print, "Removing Docker cache volumes.")
	docker volume rm lnd-go-build-cache lnd-go-mod-cache lnd-go-lint-cache || true

This would improve the developer experience by providing a managed way to handle these new resources.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding this cleanup also makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will addd

-v $$(pwd):/build lnd-tools
endif

GREEN := "\\033[0;32m"
NC := "\\033[0m"
Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -500,4 +521,5 @@ clean-mobile:
ios \
android \
mobile \
clean
clean \
clean-docker-volumes
Loading