-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
42 lines (35 loc) · 1.28 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
GIT_VERSION = $(shell git describe --always --abbrev=7 --dirty)
BASE_IMAGE_NAME = lightweight-docker-go
RC_IMAGE_NAME = $(RC_DOCKER_REPO)$(BASE_IMAGE_NAME):$(GIT_VERSION)
RC_MUTABLE_IMAGE_NAME = $(RC_DOCKER_REPO)$(BASE_IMAGE_NAME):canary
REL_IMAGE_NAME = $(REL_DOCKER_REPO)$(BASE_IMAGE_NAME):$(REL_VERSION)
REL_MUTABLE_IMAGE_NAME = $(REL_DOCKER_REPO)$(BASE_IMAGE_NAME):latest
# Checks for the existence of a docker client and prints a nice error message
# if it isn't present
.PHONY: check-docker
check-docker:
@if [ -z $$(which docker) ]; then \
echo "Missing \`docker\` client which is required for development"; \
exit 2; \
fi
# Build the Docker image
.PHONY: build
build: check-docker
docker build -t $(RC_IMAGE_NAME) .
docker tag $(RC_IMAGE_NAME) $(RC_MUTABLE_IMAGE_NAME)
# Push the release candidate Docker images
.PHONY: push-rc
push-rc: check-docker build
docker push $(RC_IMAGE_NAME)
docker push $(RC_MUTABLE_IMAGE_NAME)
# Push the release / semver Docker images
.PHONY: push-release
push-release:
ifndef REL_VERSION
$(error REL_VERSION is undefined)
endif
docker pull $(RC_IMAGE_NAME)
docker tag $(RC_IMAGE_NAME) $(REL_IMAGE_NAME)
docker tag $(RC_IMAGE_NAME) $(REL_MUTABLE_IMAGE_NAME)
docker push $(REL_IMAGE_NAME)
docker push $(REL_MUTABLE_IMAGE_NAME)