fix: keep go caches on disk instead of tmpfs /tmp

On the target host /tmp is a tmpfs sized at half of RAM (~970M), so the
go module cache and build cache together filled it and every module
download failed with "no space left on device". Move both caches to
/var/tmp, which lives on the root filesystem, and create both cache
directories up front rather than only the build cache.
This commit is contained in:
apple
2026-11-14 13:58:54 +08:00
parent 2d1b648306
commit ef2f6012e1

View File

@@ -2,8 +2,8 @@ GO_ARGS ?=
GO_PLUGIN_MAKE_TARGET ?= build GO_PLUGIN_MAKE_TARGET ?= build
GO_REPO_ROOT := /go/src/github.com/dokku/dokku GO_REPO_ROOT := /go/src/github.com/dokku/dokku
BUILD_IMAGE := hub.diyla.com/golang:1.27.3 BUILD_IMAGE := hub.diyla.com/golang:1.27.3
GO_BUILD_CACHE ?= /tmp/dokku-go-build-cache GO_BUILD_CACHE ?= /var/tmp/dokku-go-build-cache
GO_MOD_CACHE ?= /tmp/dokku-go-mod-mod GO_MOD_CACHE ?= /var/tmp/dokku-go-mod-mod
GO_ROOT_MOUNT ?= $$PWD/../..:$(GO_REPO_ROOT) GO_ROOT_MOUNT ?= $$PWD/../..:$(GO_REPO_ROOT)
ifndef TARGETARCH ifndef TARGETARCH
TARGETARCH := $(shell dpkg --print-architecture 2>/dev/null || uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/') TARGETARCH := $(shell dpkg --print-architecture 2>/dev/null || uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/')
@@ -15,7 +15,7 @@ GOARCH ?= $(TARGETARCH)
build: $(BUILD) build: $(BUILD)
build-in-docker: clean build-in-docker: clean
mkdir -p /tmp/dokku-go-build-cache mkdir -p $(GO_BUILD_CACHE) $(GO_MOD_CACHE)
docker run --rm \ docker run --rm \
-v $(GO_ROOT_MOUNT) \ -v $(GO_ROOT_MOUNT) \
-v $(GO_BUILD_CACHE):/root/.cache \ -v $(GO_BUILD_CACHE):/root/.cache \