From db906cbe4fb2a1664f35b54c7ebed74778b127f7 Mon Sep 17 00:00:00 2001 From: Heath Lord Date: Wed, 31 Jan 2024 16:46:40 -0500 Subject: [PATCH] Add manifest for docker build and CI * Add arch to Date tag, add manifest push to workflow * Copy and paste error from before, not used in CI pipeline at all --- .github/workflows/docker.yml | 6 ++++++ Makefile | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 45a12b8..33d4c6f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -27,3 +27,9 @@ jobs: run: | echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin docker push --all-tags $DOCKER_REPO + docker manifest create $DOCKER_REPO:latest $DOCKER_REPO:latest-amd64 $DOCKER_REPO:latest-arm64 + docker manifest push $DOCKER_REPO:latest + date_tag=$(docker images | grep tileserv | grep -v latest | grep -v arm64 | awk '{print $2}') + date_tag=${date_tag/-amd64/} + docker manifest create $DOCKER_REPO:${date_tag} $DOCKER_REPO:${date_tag}-amd64 $DOCKER_REPO:${date_tag}-arm64 + docker manifest push $DOCKER_REPO:${date_tag} diff --git a/Makefile b/Makefile index aa36065..ec6bd66 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ ## BASE_REGISTRY - This is the registry to pull the base image from ## BASE_IMAGE - The base image to use for the final container ## TARGETARCH - The architecture the resulting image is based on and the binary is compiled for -## IMAGE_TAG - The container and tag to be applied to the container +## IMAGE_TAG - The tag to be applied to the container APPVERSION ?= latest GOVERSION ?= 1.21.6 @@ -28,7 +28,8 @@ TARGETARCH ?= arm64 PLATFORM=arm64 endif -IMAGE_TAG ?= $(CONTAINER):$(APPVERSION)-$(TARGETARCH) +IMAGE_TAG ?= $(APPVERSION)-$(TARGETARCH) +DATE_TAG ?= $(DATE)-$(TARGETARCH) RM = /bin/rm CP = /bin/cp @@ -49,7 +50,7 @@ clean: ## This will clean all local build artifacts $(info Cleaning project...) @rm -f $(PROGRAM) @rm -rf docs/* - @docker image inspect $(CONTAINER):$(APPVERSION) >/dev/null 2>&1 && docker rmi -f $(CONTAINER):$(APPVERSION) $(CONTAINER):$(DATE) || echo -n "" + @docker image inspect $(CONTAINER):$(IMAGE_TAG) >/dev/null 2>&1 && docker rmi -f $(shell docker images --filter label=release=latest --filter=reference="*tileserv:*" -q) || echo -n "" docs: ## Generate docs @rm -rf docs/* && cd hugo && hugo && cd .. @@ -64,7 +65,7 @@ bin-docker: ## Build a local binary based off of a golang base docker i bin-for-docker: $(GOFILES) ## Build a local binary using APPVERSION parameter or CI as default (to be used in docker image) # to be used in docker the built binary needs the CGO_ENABLED=0 option - CGO_ENABLED=0 go build -v -ldflags "-s -w -X github.com/CrunchyData/pg_featureserv/conf.setVersion=$(APPVERSION)" + CGO_ENABLED=0 go build -v -ldflags "-s -w -X main.programVersion=$(APPVERSION)" build-common: Dockerfile docker build -f Dockerfile \ @@ -77,10 +78,10 @@ build-common: Dockerfile --build-arg BASE_IMAGE=$(BASE_IMAGE) \ --label vendor="Crunchy Data" \ --label url="https://crunchydata.com" \ - --label release="${APPVERSION}" \ + --label release="$(APPVERSION)" \ --label org.opencontainers.image.vendor="Crunchy Data" \ --label os.version="7.7" \ - -t $(IMAGE_TAG) -t $(CONTAINER):$(DATE) . + -t $(CONTAINER):$(IMAGE_TAG) -t $(CONTAINER):$(DATE_TAG) . docker image prune --filter label=stage=tileservbuilder -f set-local: