From a70b0c1ddc35a03701372d0a921fba5bb14264f5 Mon Sep 17 00:00:00 2001 From: Alan Rominger Date: Fri, 28 Jun 2024 09:52:59 -0400 Subject: Do not use cache in github image build action (#15308) * Do not use cache in actual image build action * Add cache args to kube prod builds --- Makefile | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 17333be6dc..91f11a1aeb 100644 --- a/Makefile +++ b/Makefile @@ -63,6 +63,8 @@ DEV_DOCKER_OWNER ?= ansible DEV_DOCKER_OWNER_LOWER = $(shell echo $(DEV_DOCKER_OWNER) | tr A-Z a-z) DEV_DOCKER_TAG_BASE ?= ghcr.io/$(DEV_DOCKER_OWNER_LOWER) DEVEL_IMAGE_NAME ?= $(DEV_DOCKER_TAG_BASE)/awx_devel:$(COMPOSE_TAG) +IMAGE_KUBE_DEV=$(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) +IMAGE_KUBE=$(DEV_DOCKER_TAG_BASE)/awx:$(COMPOSE_TAG) # Common command to use for running ansible-playbook ANSIBLE_PLAYBOOK ?= ansible-playbook -e ansible_python_interpreter=$(PYTHON) @@ -89,6 +91,18 @@ I18N_FLAG_FILE = .i18n_built ## PLATFORMS defines the target platforms for the manager image be build to provide support to multiple PLATFORMS ?= linux/amd64,linux/arm64 # linux/ppc64le,linux/s390x +# Set up cache variables for image builds, allowing to control whether cache is used or not, ex: +# DOCKER_CACHE=--no-cache make docker-compose-build +ifeq ($(DOCKER_CACHE),) + DOCKER_DEVEL_CACHE_FLAG=--cache-from=$(DEVEL_IMAGE_NAME) + DOCKER_KUBE_DEV_CACHE_FLAG=--cache-from=$(IMAGE_KUBE_DEV) + DOCKER_KUBE_CACHE_FLAG=--cache-from=$(IMAGE_KUBE) +else + DOCKER_DEVEL_CACHE_FLAG=$(DOCKER_CACHE) + DOCKER_KUBE_DEV_CACHE_FLAG=$(DOCKER_CACHE) + DOCKER_KUBE_CACHE_FLAG=$(DOCKER_CACHE) +endif + .PHONY: awx-link clean clean-tmp clean-venv requirements requirements_dev \ develop refresh adduser migrate dbchange \ receiver test test_unit test_coverage coverage_html \ @@ -606,8 +620,7 @@ docker-compose-build: Dockerfile.dev -f Dockerfile.dev \ -t $(DEVEL_IMAGE_NAME) \ --build-arg BUILDKIT_INLINE_CACHE=1 \ - --cache-from=$(DEV_DOCKER_TAG_BASE)/awx_devel:$(COMPOSE_TAG) . - + $(DOCKER_DEVEL_CACHE_FLAG) . .PHONY: docker-compose-buildx ## Build awx_devel image for docker compose development environment for multiple architectures @@ -617,7 +630,7 @@ docker-compose-buildx: Dockerfile.dev - docker buildx build \ --push \ --build-arg BUILDKIT_INLINE_CACHE=1 \ - --cache-from=$(DEV_DOCKER_TAG_BASE)/awx_devel:$(COMPOSE_TAG) \ + $(DOCKER_DEVEL_CACHE_FLAG) \ --platform=$(PLATFORMS) \ --tag $(DEVEL_IMAGE_NAME) \ -f Dockerfile.dev . @@ -680,7 +693,8 @@ awx-kube-build: Dockerfile --build-arg VERSION=$(VERSION) \ --build-arg SETUPTOOLS_SCM_PRETEND_VERSION=$(VERSION) \ --build-arg HEADLESS=$(HEADLESS) \ - -t $(DEV_DOCKER_TAG_BASE)/awx:$(COMPOSE_TAG) . + $(DOCKER_KUBE_CACHE_FLAG) \ + -t $(IMAGE_KUBE) . ## Build multi-arch awx image for deployment on Kubernetes environment. awx-kube-buildx: Dockerfile @@ -692,7 +706,8 @@ awx-kube-buildx: Dockerfile --build-arg SETUPTOOLS_SCM_PRETEND_VERSION=$(VERSION) \ --build-arg HEADLESS=$(HEADLESS) \ --platform=$(PLATFORMS) \ - --tag $(DEV_DOCKER_TAG_BASE)/awx:$(COMPOSE_TAG) \ + $(DOCKER_KUBE_CACHE_FLAG) \ + --tag $(IMAGE_KUBE) \ -f Dockerfile . - docker buildx rm awx-kube-buildx @@ -710,8 +725,8 @@ Dockerfile.kube-dev: tools/ansible/roles/dockerfile/templates/Dockerfile.j2 awx-kube-dev-build: Dockerfile.kube-dev DOCKER_BUILDKIT=1 docker build -f Dockerfile.kube-dev \ --build-arg BUILDKIT_INLINE_CACHE=1 \ - --cache-from=$(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) \ - -t $(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) . + $(DOCKER_KUBE_DEV_CACHE_FLAG) \ + -t $(IMAGE_KUBE_DEV) . ## Build and push multi-arch awx_kube_devel image for development on local Kubernetes environment. awx-kube-dev-buildx: Dockerfile.kube-dev @@ -720,14 +735,14 @@ awx-kube-dev-buildx: Dockerfile.kube-dev - docker buildx build \ --push \ --build-arg BUILDKIT_INLINE_CACHE=1 \ - --cache-from=$(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) \ + $(DOCKER_KUBE_DEV_CACHE_FLAG) \ --platform=$(PLATFORMS) \ - --tag $(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) \ + --tag $(IMAGE_KUBE_DEV) \ -f Dockerfile.kube-dev . - docker buildx rm awx-kube-dev-buildx kind-dev-load: awx-kube-dev-build - $(KIND_BIN) load docker-image $(DEV_DOCKER_TAG_BASE)/awx_kube_devel:$(COMPOSE_TAG) + $(KIND_BIN) load docker-image $(IMAGE_KUBE_DEV) # Translation TASKS # -------------------------------------- -- cgit v1.2.3