Skip to content

Commit 866510a

Browse files
author
Seth Goings
committed
feat(Makefile): enable immutable (git-based) Docker tag publishing
1 parent 39eef5d commit 866510a

3 files changed

Lines changed: 30 additions & 13 deletions

File tree

Makefile

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22
DEIS_REGISTRY ?= $(DEV_REGISTRY)
33
IMAGE_PREFIX ?= deis
44
COMPONENT ?= workflow
5-
VERSION ?= git-$(shell git rev-parse --short HEAD)
6-
IMAGE = $(DEIS_REGISTRY)$(IMAGE_PREFIX)/$(COMPONENT):$(VERSION)
5+
SHORT_NAME ?= $(COMPONENT)
6+
7+
include versioning.mk
8+
79
SHELL_SCRIPTS = $(wildcard rootfs/bin/*) $(shell find "rootfs" -name '*.sh') $(wildcard _scripts/*.sh)
810

911
# Get the component informtation to a tmp location and get replica count
1012
$(shell kubectl get rc deis-$(COMPONENT) --namespace deis -o yaml > /tmp/deis-$(COMPONENT))
1113
DESIRED_REPLICAS=$(shell kubectl get -o template rc/deis-$(COMPONENT) --template={{.status.replicas}} --namespace deis)
1214

13-
info:
14-
@echo "Build tag: ${VERSION}"
15-
@echo "Registry: ${DEIS_REGISTRY}"
16-
@echo "Image: ${IMAGE}"
17-
1815
check-docker:
1916
@if [ -z $$(which docker) ]; then \
2017
echo "Missing \`docker\` client which is required for development"; \
@@ -24,10 +21,8 @@ check-docker:
2421
build: docker-build
2522

2623
docker-build: check-docker
27-
docker build --rm -t $(IMAGE) rootfs
28-
29-
docker-push:
30-
docker push ${IMAGE}
24+
docker build --rm -t ${IMAGE} rootfs
25+
docker tag -f ${IMAGE} ${MUTABLE_IMAGE}
3126

3227
deploy: docker-build docker-push
3328
sed 's#\(image:\) .*#\1 $(IMAGE)#' /tmp/deis-$(COMPONENT) | kubectl apply --validate=true -f -
@@ -73,6 +68,6 @@ test-functional:
7368
@echo "Implement functional tests in _tests directory"
7469

7570
test-integration:
76-
@echo "Check https://github.com/deis/workflow-e2e for the complete interation test suite"
71+
@echo "Check https://github.com/deis/workflow-e2e for the complete integration test suite"
7772

7873
.PHONY: build clean commit-hook full-clean postgres setup-venv test test-style test-unit test-functional

_scripts/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
cd "$(dirname "$0")" || exit 1
77

8-
export IMAGE_PREFIX=deisci VERSION=v2-beta
8+
export IMAGE_PREFIX=deisci
99
docker login -e="$DOCKER_EMAIL" -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
1010
DEIS_REGISTRY='' make -C .. docker-build docker-push
1111
docker login -e="$QUAY_EMAIL" -u="$QUAY_USERNAME" -p="$QUAY_PASSWORD" quay.io

versioning.mk

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MUTABLE_VERSION ?= canary
2+
VERSION ?= git-$(shell git rev-parse --short HEAD)
3+
4+
IMAGE := ${DEIS_REGISTRY}${IMAGE_PREFIX}/${SHORT_NAME}:${VERSION}
5+
MUTABLE_IMAGE := ${DEIS_REGISTRY}${IMAGE_PREFIX}/${SHORT_NAME}:${MUTABLE_VERSION}
6+
7+
info:
8+
@echo "Build tag: ${VERSION}"
9+
@echo "Registry: ${DEIS_REGISTRY}"
10+
@echo "Immutable tag: ${IMAGE}"
11+
@echo "Mutable tag: ${MUTABLE_IMAGE}"
12+
13+
.PHONY: docker-push
14+
docker-push: docker-immutable-push docker-mutable-push
15+
16+
.PHONY: docker-immutable-push
17+
docker-immutable-push:
18+
docker push ${IMAGE}
19+
20+
.PHONY: docker-mutable-push
21+
docker-mutable-push:
22+
docker push ${MUTABLE_IMAGE}

0 commit comments

Comments
 (0)