docker: Override GOMODCACHE to always use a writable location (#6899)

This commit is contained in:
Gus Luxton 2021-05-20 02:14:12 -03:00 committed by GitHub
parent b8f60b921d
commit 1743ea7210
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -289,7 +289,7 @@ test-api:
test-api: FLAGS ?= '-race'
test-api: PACKAGES := $(shell cd api && go list ./...)
test-api: $(VERSRC)
GOMODCACHE=/tmp go test -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" $(PACKAGES) $(FLAGS) $(ADDFLAGS)
go test -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" $(PACKAGES) $(FLAGS) $(ADDFLAGS)
# Find and run all shell script unit tests (using https://github.com/bats-core/bats-core)
.PHONY: test-sh
@ -341,7 +341,7 @@ lint-go:
.PHONY: lint-api
lint-api: GO_LINT_API_FLAGS ?=
lint-api:
cd api && GOMODCACHE=/tmp golangci-lint run -c ../.golangci.yml $(GO_LINT_API_FLAGS)
cd api && golangci-lint run -c ../.golangci.yml $(GO_LINT_API_FLAGS)
# TODO(awly): remove the `--exclude` flag after cleaning up existing scripts
.PHONY: lint-sh

View file

@ -3,7 +3,8 @@
#
HOSTNAME=buildbox
SRCDIR=/go/src/github.com/gravitational/teleport
DOCKERFLAGS := --rm=true -v "$$(pwd)/../":$(SRCDIR) -v /tmp:/tmp -w $(SRCDIR) -h $(HOSTNAME)
GOMODCACHE ?= /tmp/gomodcache
DOCKERFLAGS := --rm=true -v "$$(pwd)/../":$(SRCDIR) -v /tmp:/tmp -w $(SRCDIR) -h $(HOSTNAME) -e GOMODCACHE=$(GOMODCACHE)
BCCFLAGS := -v "$$(pwd)/bcc:/usr/include/bcc"
ADDFLAGS ?=
BATSFLAGS :=
@ -190,6 +191,7 @@ grpc: buildbox
clean:
docker image rm --force $(BUILDBOX)
docker image rm --force $(DOCSBOX)
GOMODCACHE=$(GOMODCACHE) go clean -modcache
#
# Runs tests inside a build container