forked from UN-OCHA/docker-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.conf
57 lines (48 loc) · 1.51 KB
/
Makefile.conf
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# The DockerHub repository name.
# This will also be used as the organisation tag in the image.
ORGANISATION=unocha
# Miscellaneous utilities used by the build scripts.
AWK=/usr/bin/awk
DOCKER=docker
ECHO=echo
GREP=grep -E
MAKE=make
RM=rm
SED=sed
# Initialise empty variables.
UPSTREAM=
VERSION=
EXTRAVERSION=
EXTRAOPTIONS=
# Common build targets.
build: clean template
$(DOCKER) build \
--no-cache \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg VCS_URL=`git config --get remote.origin.url | sed 's#[email protected]:#https://github.com/#'` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg VERSION=$(VERSION) \
$(EXTRAOPTIONS) \
. | tee buildlog.txt
# Create a Dockerfile from the template.
template:
@$(ECHO) "Generating a Dockerfile for version $(UPSTREAM)"
@$(SED) "s/%%UPSTREAM%%/$(UPSTREAM)/" < Dockerfile.tmpl > Dockerfile
# Tag the image with our organisation, name and version.
tag:
@$(ECHO) "Tagging the built image."
$(eval IMAGE_HASH=$(shell tail -n 1 buildlog.txt | $(AWK) '{print $$NF}'))
$(DOCKER) tag $(IMAGE_HASH) $(ORGANISATION)/$(IMAGE):$(VERSION)$(EXTRAVERSION)
# Remove the buildlog.
clean:
$(RM) -f Dockerfile buildlog.txt
# Push the tagged image to DockerHub.
push:
$(DOCKER) push $(ORGANISATION)/$(IMAGE):$(VERSION)$(EXTRAVERSION)
# Remove intermediate images.
clean_images:
@echo Clean up intemediate images.
for i in `$(GREP) '^ ---> ([a-z0-9]){12}$$' buildlog.txt | $(AWK) '{print $$2}'`; do \
$(DOCKER) rmi -f $$i; \
done
.PHONY: build tag clean