From 470884a4353e3bb187ca9d90bdd3806316a9b71f Mon Sep 17 00:00:00 2001 From: Mohammed Safwan Aslam Kazi <76790986+safwank97@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:03:17 -0400 Subject: [PATCH] Automate Local Image Pruning (#3587) * adding labels to each stage in docker file ci-rp * added a new makefile target ci-clean to prune local images * removing ci-portal from .PHONY accidentally came with previous commit --- Dockerfile.ci-rp | 3 +++ Makefile | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile.ci-rp b/Dockerfile.ci-rp index c1d60854178..69c06f318d7 100644 --- a/Dockerfile.ci-rp +++ b/Dockerfile.ci-rp @@ -6,6 +6,7 @@ ARG ARO_VERSION # builder is responsible for all compilation and validation of the RP ############################################################################### FROM ${REGISTRY}/ubi8/nodejs-16 as portal-build +LABEL aro-portal-build=true WORKDIR /build/portal/v2 USER root @@ -23,6 +24,7 @@ RUN npm run lint && npm run build ############################################################################### FROM ${REGISTRY}/ubi8/go-toolset:1.20.12-5 AS builder ARG ARO_VERSION +LABEL aro-builder=true USER root WORKDIR /app @@ -61,6 +63,7 @@ RUN hack/fips/validate-fips.sh ./aro # Stage 3: final is our slim image with minimal layers and tools ############################################################################### FROM ${REGISTRY}/ubi8/ubi-minimal AS final +LABEL aro-final=true RUN microdnf update && microdnf clean all COPY --from=builder /app/aro /app/e2e.test /usr/local/bin/ ENTRYPOINT ["aro"] diff --git a/Makefile b/Makefile index d263c3e8d85..4ee39b0225b 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,9 @@ client: generate ci-rp: fix-macos-vendor docker build . -f Dockerfile.ci-rp --ulimit=nofile=4096:4096 --build-arg REGISTRY=$(REGISTRY) --build-arg ARO_VERSION=$(VERSION) --no-cache=$(NO_CACHE) +ci-clean: + docker image prune --all --filter="label=aro-*=true" + # TODO: hard coding dev-config.yaml is clunky; it is also probably convenient to # override COMMIT. deploy: @@ -278,4 +281,4 @@ vendor: install-go-tools: go install ${GOTESTSUM} -.PHONY: admin.kubeconfig aks.kubeconfig aro az ci-portal ci-rp clean client deploy dev-config.yaml discoverycache fix-macos-vendor generate image-aro-multistage image-fluentbit image-proxy init-contrib lint-go runlocal-rp proxy publish-image-aro-multistage publish-image-fluentbit publish-image-proxy secrets secrets-update e2e.test tunnel test-e2e test-go test-python vendor build-all validate-go unit-test-go coverage-go validate-fips install-go-tools +.PHONY: admin.kubeconfig aks.kubeconfig aro az ci-rp ci-clean clean client deploy dev-config.yaml discoverycache fix-macos-vendor generate image-aro-multistage image-fluentbit image-proxy init-contrib lint-go runlocal-rp proxy publish-image-aro-multistage publish-image-fluentbit publish-image-proxy secrets secrets-update e2e.test tunnel test-e2e test-go test-python vendor build-all validate-go unit-test-go coverage-go validate-fips install-go-tools