use uuid to invalidate cache

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2022-01-13 13:47:43 +01:00
parent caa31d9374
commit 663f01b9cc
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
3 changed files with 4 additions and 9 deletions

View File

@ -90,16 +90,12 @@ target "update-vendor" {
output = ["."]
}
// Used to invalidate cache for mod-outdated run stage
// See also https://github.com/moby/buildkit/issues/1213
variable "TIMESTAMP" {
default = ""
}
target "mod-outdated" {
dockerfile = "./dockerfiles/Dockerfile.vendor"
target = "outdated"
args = {
TIMESTAMP = TIMESTAMP
// used to invalidate cache (more info https://github.com/moby/buildkit/issues/1213)
UUID = uuidv4()
}
output = ["type=cacheonly"]
}

View File

@ -20,7 +20,6 @@ ifeq ($(DOCKER_CLI_GO_BUILD_CACHE),y)
DOCKER_CLI_MOUNTS += -v "$(CACHE_VOLUME_NAME):/root/.cache/go-build"
endif
VERSION = $(shell cat VERSION)
TIMESTAMP = $(shell date '+%s')
ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e PLATFORM -e TESTFLAGS -e TESTDIRS -e GOOS -e GOARCH -e GOARM -e TEST_ENGINE_VERSION=$(E2E_ENGINE_VERSION)
# Some Dockerfiles use features that are only supported with BuildKit enabled
@ -94,7 +93,7 @@ validate-vendor: ## validate vendor
.PHONY: mod-outdated
mod-outdated: ## check outdated dependencies
TIMESTAMP=$(TIMESTAMP) docker buildx bake mod-outdated
docker buildx bake mod-outdated
.PHONY: authors
authors: ## generate AUTHORS file from git history

View File

@ -34,7 +34,7 @@ EOT
FROM psampaz/go-mod-outdated:${MODOUTDATED_VERSION} AS go-mod-outdated
FROM base AS outdated
ARG TIMESTAMP
ARG UUID
RUN --mount=target=.,rw \
--mount=target=/go/pkg/mod,type=cache \
--mount=from=go-mod-outdated,source=/home/go-mod-outdated,target=/usr/bin/go-mod-outdated \