From c2e49b53fbe3d59f17e667d744ebb80d7255e51a Mon Sep 17 00:00:00 2001 From: Chris Bandy Date: Tue, 12 Aug 2025 13:37:10 -0500 Subject: [PATCH 1/2] Cache Go modules in development builds --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index a218dfe49..38f3fa782 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ COPY hack/tools/queries /opt/crunchy/conf WORKDIR /usr/src/app COPY . . ENV GOCACHE=/var/cache/go +ENV GOMODCACHE=/var/cache/go/mod RUN --mount=type=cache,target=/var/cache/go go build ./cmd/postgres-operator FROM docker.io/library/debian:bookworm From 59a3201767c767ed9f7ab16e5bb8760ce42506da Mon Sep 17 00:00:00 2001 From: Chris Bandy Date: Tue, 12 Aug 2025 13:38:15 -0500 Subject: [PATCH 2/2] Add Make targets that push to development clusters --- Makefile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 680884e0f..49cafb632 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ +IMAGE ?= localhost/postgres-operator:latest PGMONITOR_DIR ?= hack/tools/pgmonitor PGMONITOR_VERSION ?= v5.2.1 QUERIES_CONFIG_DIR ?= hack/tools/queries @@ -44,7 +45,7 @@ notes: ## List known issues and future considerations .PHONY: clean clean: ## Clean resources clean: clean-deprecated - rm -f bin/postgres-operator + rm -f bin/postgres-operator image.tar rm -rf licenses/*/ [ ! -d testing/kuttl/e2e-generated ] || rm -r testing/kuttl/e2e-generated [ ! -d hack/tools/envtest ] || { chmod -R u+w hack/tools/envtest && rm -r hack/tools/envtest; } @@ -133,7 +134,7 @@ deploy-dev: createnamespaces .PHONY: build build: ## Build a postgres-operator image - $(BUILDAH) build --tag localhost/postgres-operator \ + $(BUILDAH) build --tag '$(IMAGE)' \ --label org.opencontainers.image.authors='Crunchy Data' \ --label org.opencontainers.image.description='Crunchy PostgreSQL Operator' \ --label org.opencontainers.image.revision='$(shell git rev-parse HEAD)' \ @@ -141,6 +142,17 @@ build: ## Build a postgres-operator image --label org.opencontainers.image.title='Crunchy PostgreSQL Operator' \ . +build-k3d: image.tar ; $(or $(K3D),k3d) image import $< +build-kind: image.tar ; $(or $(KIND),kind) load image-archive $< +build-minikube: image.tar ; $(or $(MINIKUBE),minikube) image load $< + +image.tar: build + set -x && \ + case '$(BUILDAH)' in \ + *docker*) $(BUILDAH) image save '--output=$@' '$(IMAGE)' ;; \ + *) $(BUILDAH) push '$(IMAGE)' 'oci-archive:$@:$(IMAGE)' ;; \ + esac + ##@ Test .PHONY: check