diff --git a/.github/workflows/build-images-base.yaml b/.github/workflows/build-images-base.yaml index f4f95b11d..d2cfffaee 100644 --- a/.github/workflows/build-images-base.yaml +++ b/.github/workflows/build-images-base.yaml @@ -35,6 +35,10 @@ on: description: Bundle and catalog channels, comma separated default: preview type: string + quayImageExpiry: + description: When to expire the built quay images. The time values could be something like 1h, 2d, 3w for hours, days, and weeks, respectively, from the time the image is built. + default: never + type: string workflow_dispatch: inputs: kuadrantOperatorTag: @@ -69,6 +73,10 @@ on: description: Bundle and catalog channels, comma separated default: preview type: string + quayImageExpiry: + description: When to expire the built quay images. The time values could be something like 1h, 2d, 3w for hours, days, and weeks, respectively, from the time the image is built. + default: never + type: string env: IMG_TAGS: ${{ inputs.kuadrantOperatorTag }} @@ -107,6 +115,7 @@ jobs: provenance: false tags: | ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}:${{ env.IMG_TAGS }} + build-args: QUAY_IMAGE_EXPIRY=${{ inputs.quayImageExpiry }} - name: Print Image URL run: echo "Image pushed to ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}:${{ env.IMG_TAGS }}" @@ -155,6 +164,7 @@ jobs: provenance: false tags: | ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-bundle:${{ env.IMG_TAGS }} + build-args: QUAY_IMAGE_EXPIRY=${{ inputs.quayImageExpiry }} - name: Print Bundle Image URL run: echo "Bundle image pushed to ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-bundle:${{ env.IMG_TAGS }}" @@ -202,5 +212,6 @@ jobs: provenance: false tags: | ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-catalog:${{ env.IMG_TAGS }} + build-args: QUAY_IMAGE_EXPIRY=${{ inputs.quayImageExpiry }} - name: Print Catalog Image URL run: echo "Catalog image pushed to ${{ env.IMG_REGISTRY_HOST }}/${{ env.IMG_REGISTRY_ORG }}/${{ env.OPERATOR_NAME }}-catalog:${{ env.IMG_TAGS }}" \ No newline at end of file diff --git a/.github/workflows/build-images-branches.yaml b/.github/workflows/build-images-branches.yaml index 065191a50..5e0a66f40 100644 --- a/.github/workflows/build-images-branches.yaml +++ b/.github/workflows/build-images-branches.yaml @@ -13,3 +13,4 @@ jobs: with: kuadrantOperatorVersion: ${{ github.ref_name }} kuadrantOperatorTag: ${{ github.ref_name }} + quayImageExpiry: 1w \ No newline at end of file diff --git a/.github/workflows/build-images-nightly.yaml b/.github/workflows/build-images-nightly.yaml index 6966a4cfc..e88c84c9f 100644 --- a/.github/workflows/build-images-nightly.yaml +++ b/.github/workflows/build-images-nightly.yaml @@ -25,3 +25,4 @@ jobs: limitadorOperatorVersion: ${{ vars.LIMITADOR_OPERATOR_SHA }} dnsOperatorVersion: ${{ vars.DNS_OPERATOR_SHA }} wasmShimVersion: ${{ vars.WASM_SHIM_SHA }} + quayImageExpiry: 2w diff --git a/Dockerfile b/Dockerfile index b2e105887..75958ebc2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM --platform=$BUILDPLATFORM golang:1.22 as builder +FROM --platform=$BUILDPLATFORM golang:1.22 AS builder WORKDIR /workspace # Copy the Go Modules manifests @@ -28,4 +28,9 @@ WORKDIR / COPY --from=builder /workspace/manager . USER 65532:65532 +# Quay image expiry +ARG QUAY_IMAGE_EXPIRY +ENV QUAY_IMAGE_EXPIRY=${QUAY_IMAGE_EXPIRY:-never} +LABEL quay.expires-after=$QUAY_IMAGE_EXPIRY + ENTRYPOINT ["/manager"] diff --git a/Makefile b/Makefile index cc87545a7..a6290edd1 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ SHELL = /usr/bin/env bash -o pipefail MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH))) +QUAY_IMAGE_EXPIRY ?= never + # Container Engine to be used for building image and with kind CONTAINER_ENGINE ?= docker @@ -341,7 +343,7 @@ run: generate fmt vet ## Run a controller from your host. go run ./main.go docker-build: ## Build docker image with the manager. - $(CONTAINER_ENGINE) build -t $(IMG) . + $(CONTAINER_ENGINE) build --build-arg QUAY_IMAGE_EXPIRY=$(QUAY_IMAGE_EXPIRY) -t $(IMG) . docker-push: ## Push docker image with the manager. $(CONTAINER_ENGINE) push $(IMG) diff --git a/bundle.Dockerfile b/bundle.Dockerfile index f5f5e8dc8..7f3bdf69d 100644 --- a/bundle.Dockerfile +++ b/bundle.Dockerfile @@ -15,6 +15,11 @@ LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3 LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1 LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/ +# Quay image expiry +ARG QUAY_IMAGE_EXPIRY +ENV QUAY_IMAGE_EXPIRY=${QUAY_IMAGE_EXPIRY:-never} +LABEL quay.expires-after=$QUAY_IMAGE_EXPIRY + # Copy files to locations specified by labels. COPY bundle/manifests /manifests/ COPY bundle/metadata /metadata/