Skip to content

Commit 7b97cf9

Browse files
author
Seth Goings
committed
feat(Makefile): enable immutable (git-based) Docker tag publishing
1 parent ea1712f commit 7b97cf9

3 files changed

Lines changed: 27 additions & 24 deletions

File tree

Makefile

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
SHORT_NAME ?= builder
22

3+
include versioning.mk
4+
35
# Enable vendor/ directory support.
46
export GO15VENDOREXPERIMENT=1
57

@@ -12,21 +14,14 @@ DEV_ENV_CMD := ${DEV_ENV_PREFIX} ${DEV_ENV_IMAGE}
1214

1315
# SemVer with build information is defined in the SemVer 2 spec, but Docker
1416
# doesn't allow +, so we use -.
15-
VERSION ?= git-$(shell git rev-parse --short HEAD)
1617
BINARY_DEST_DIR := rootfs/usr/bin
1718
# Common flags passed into Go's linker.
1819
LDFLAGS := "-s -X main.version=${VERSION}"
19-
IMAGE_PREFIX ?= deis
2020
# Docker Root FS
2121
BINDIR := ./rootfs
2222

2323
DEIS_REGISTRY ?= ${DEV_REGISTRY}/
2424

25-
# Kubernetes-specific information for RC, Service, and Image.
26-
RC := manifests/deis-${SHORT_NAME}-rc.yaml
27-
SVC := manifests/deis-${SHORT_NAME}-service.yaml
28-
IMAGE := ${DEIS_REGISTRY}${IMAGE_PREFIX}/${SHORT_NAME}:${VERSION}
29-
3025
all:
3126
@echo "Use a Makefile to control top-level building of the project."
3227

@@ -49,27 +44,12 @@ test:
4944

5045
docker-build:
5146
docker build --rm -t ${IMAGE} rootfs
47+
docker tag -f ${IMAGE} ${MUTABLE_IMAGE}
5248

5349
# Push to a registry that Kubernetes can access.
5450
docker-push:
5551
docker push ${IMAGE}
5652

57-
# Deploy is a Kubernetes-oriented target
58-
deploy: kube-service kube-rc
59-
60-
# Some things, like services, have to be deployed before pods. This is an
61-
# example target. Others could perhaps include kube-secret, kube-volume, etc.
62-
kube-service:
63-
kubectl create -f ${SVC}
64-
65-
# When possible, we deploy with RCs.
66-
kube-rc:
67-
kubectl create -f ${RC}
68-
69-
kube-clean:
70-
kubectl delete rc deis-${SHORT_NAME}
71-
kubectl delete svc deis-${SHORT_NAME}
72-
7353
.PHONY: all build docker-compile kube-up kube-down deploy
7454

7555
define check-static-binary

_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 .. build 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)