Skip to content

Commit 81326fa

Browse files
author
Keerthan Mala
committed
feat(Makefile): enable immutable (git-based) Docker tag publishing
1 parent 573407a commit 81326fa

3 files changed

Lines changed: 26 additions & 8 deletions

File tree

Makefile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
include includes.mk
2-
31
# Short name: Short name, following [a-zA-Z_], used all over the place.
42
# Some uses for short name:
53
# - Docker image name
64
# - Kubernetes service, rc, pod, secret, volume names
75
SHORT_NAME := registry
86

9-
VERSION ?= git-$(shell git rev-parse --short HEAD)
7+
include includes.mk versioning.mk
108

119
# the filepath to this repository, relative to $GOPATH/src
1210
REPO_PATH = github.com/deis/registry
@@ -22,9 +20,6 @@ BINDIR := ./rootfs/opt/registry/sbin
2220
# Legacy support for DEV_REGISTRY, plus new support for DEIS_REGISTRY.
2321
DEIS_REGISTRY ?= ${DEV_REGISTRY}
2422

25-
IMAGE_PREFIX ?= deis
26-
27-
2823
ifeq ($(STORAGE_TYPE),)
2924
STORAGE_TYPE = fs
3025
endif
@@ -33,7 +28,6 @@ endif
3328
SECRET := contrib/kubernetes/manifests/${SHORT_NAME}-${STORAGE_TYPE}-secret.yaml
3429
RC := contrib/kubernetes/manifests/${SHORT_NAME}-rc.yaml
3530
SVC := contrib/kubernetes/manifests/${SHORT_NAME}-service.yaml
36-
IMAGE := ${DEIS_REGISTRY}${IMAGE_PREFIX}/${SHORT_NAME}:${VERSION}
3731

3832
all:
3933
@echo "Use a Makefile to control top-level building of the project."
@@ -46,6 +40,7 @@ build: check-docker
4640
# We also alter the RC file to set the image name.
4741
docker-build: check-docker build
4842
docker build --rm -t ${IMAGE} .
43+
docker tag -f ${IMAGE} ${MUTABLE_IMAGE}
4944

5045
# Push to a registry that Kubernetes can access.
5146
docker-push: check-docker check-registry

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

0 commit comments

Comments
 (0)