Files
dokku/common.mk
T
apple ef2f6012e1
dependency-updates / prepare (push) Has been cancelled
dependency-updates / update / ${{ matrix.name }} (push) Has been cancelled
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.
2026-11-14 13:58:54 +08:00

53 lines
1.7 KiB
Makefile

GO_ARGS ?=
GO_PLUGIN_MAKE_TARGET ?= build
GO_REPO_ROOT := /go/src/github.com/dokku/dokku
BUILD_IMAGE := hub.diyla.com/golang:1.27.3
GO_BUILD_CACHE ?= /var/tmp/dokku-go-build-cache
GO_MOD_CACHE ?= /var/tmp/dokku-go-mod-mod
GO_ROOT_MOUNT ?= $$PWD/../..:$(GO_REPO_ROOT)
ifndef TARGETARCH
TARGETARCH := $(shell dpkg --print-architecture 2>/dev/null || uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/')
endif
GOARCH ?= $(TARGETARCH)
.PHONY: build-in-docker build clean src-clean
build: $(BUILD)
build-in-docker: clean
mkdir -p $(GO_BUILD_CACHE) $(GO_MOD_CACHE)
docker run --rm \
-v $(GO_ROOT_MOUNT) \
-v $(GO_BUILD_CACHE):/root/.cache \
-v $(GO_MOD_CACHE):/go/pkg/mod \
-e PLUGIN_NAME=$(PLUGIN_NAME) \
-e GO111MODULE=on \
-e "GOPROXY=https://goproxy.cn|https://mirrors.aliyun.com/goproxy/|direct" \
-w $(GO_REPO_ROOT)/plugins/$(PLUGIN_NAME) \
$(BUILD_IMAGE) \
bash -c "GO_ARGS='$(GO_ARGS)' CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) GOWORK=off make -j4 $(GO_PLUGIN_MAKE_TARGET)" || exit $$?
clean:
rm -rf $(BUILD)
find . -xtype l -delete
commands: **/**/commands.go
GOARCH=$(GOARCH) go build -mod=readonly -ldflags="-s -w" $(GO_ARGS) -o commands src/commands/commands.go
subcommands:
GOARCH=$(GOARCH) go build -mod=readonly -ldflags="-s -w" $(GO_ARGS) -o subcommands/subcommands src/subcommands/subcommands.go
$(MAKE) $(SUBCOMMANDS)
subcommands/%:
ln -sf subcommands $@
src-clean:
rm -rf .gitignore src vendor Makefile *.go glide.* go.sum go.mod
triggers:
GOARCH=$(GOARCH) go build -mod=readonly -ldflags="-s -w" $(GO_ARGS) -o triggers src/triggers/triggers.go
$(MAKE) $(TRIGGERS)
triggers/%:
ln -sf triggers $(shell echo $@ | cut -d '/' -f2)