forked from namsral/flag
-
Notifications
You must be signed in to change notification settings - Fork 4
/
variables.mk
46 lines (41 loc) · 1.89 KB
/
variables.mk
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
APPLICATION := $(shell basename `pwd`)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
BUILD_RFC3339 := $(shell date -u +"%Y-%m-%dT%H:%M:%S+00:00")
PACKAGE := $(shell git remote get-url --push origin | sed -E 's/.+[@|/].+[/|:](.+)\/(.+).git/\1\/\2/')
REVISION := $(shell git rev-parse HEAD)
VERSION := $(shell git describe --tags)
DESCRIPTION := $(shell curl -s https://api.github.com/repos/${PACKAGE} \
| grep '"description".*' \
| head -n 1 \
| cut -d '"' -f 4)
WORKDIR := $(shell pwd)
DOCKER_BUILD_ARGS := \
--build-arg APPLICATION=${APPLICATION} \
--build-arg BUILD_RFC3339=${BUILD_RFC3339} \
--build-arg DESCRIPTION="${DESCRIPTION}" \
--build-arg PACKAGE=${PACKAGE} \
--build-arg REVISION=${REVISION} \
--build-arg VERSION=${VERSION} \
--progress auto
.PHONY: debug-variables docker update-hooks
.PHONY: debug-variables
debug-variables:
@echo "APPLICATION: ${APPLICATION}"
@echo "BRANCH: ${BRANCH}"
@echo "BUILD_RFC3339: ${BUILD_RFC3339}"
@echo "DESCRIPTION: ${DESCRIPTION}"
@echo "PACKAGE: ${PACKAGE}"
@echo "REVISION: ${REVISION}"
@echo "VERSION: ${VERSION}"
@echo "WORKDIR: ${WORKDIR}"
# docker removes and rebuilds the docker container for local development
docker:
docker rmi ${APPLICATION}:${BRANCH} || true
docker build ${DOCKER_BUILD_ARGS} -t ${APPLICATION}:${BRANCH} .
# update-hooks downloads the newest version of any multi-arch hooks from the parent template repository
update-hooks:
curl -Lo hooks/build https://github.com/jnovack/docker-multi-arch-hooks/raw/master/hooks/build
curl -Lo hooks/post_checkout https://github.com/jnovack/docker-multi-arch-hooks/raw/master/hooks/post_checkout
curl -Lo hooks/post_push https://github.com/jnovack/docker-multi-arch-hooks/raw/master/hooks/post_push
curl -Lo variables.mk https://github.com/jnovack/docker-multi-arch-hooks/raw/master/variables.mk
curl -Lo go.mk https://github.com/jnovack/docker-multi-arch-hooks/raw/master/go.mk