Skip to content

Commit

Permalink
Add manifest for docker build and CI
Browse files Browse the repository at this point in the history
* Add arch to Date tag, add manifest push to workflow

* Copy and paste error from before, not used in CI pipeline at all
  • Loading branch information
crunchyheath authored Jan 31, 2024
1 parent 4888a39 commit db906cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 ..
Expand All @@ -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 \
Expand All @@ -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:
Expand Down

0 comments on commit db906cb

Please sign in to comment.