-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
43 lines (33 loc) · 1.01 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
43
# For a shorter version
# git rev-parse --short HEAD
VERSION := $(shell git rev-parse --short HEAD)
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
# $ date -R
# Wed, 11 Jul 2018 10:25:26 +0800
# $ date -u +"%Y-%m-%dT%H:%M:%SZ"
# 2018-07-11T02:25:23Z
VCS_URL := $(shell git config --get remote.origin.url)
# $(shell git log -1 --pretty=%h)
VCS_REF := $(shell git rev-parse HEAD)
NAME := $(shell basename `git rev-parse --show-toplevel`)
VENDOR := $(shell whoami)
print:
@echo VERSION=${VERSION}
@echo BUILD_DATE=${BUILD_DATE}
@echo VCS_URL=${VCS_URL}
@echo VCS_REF=${VCS_REF}
@echo NAME=${NAME}
@echo VENDOR=${VENDOR}
build:
docker build \
--build-arg VERSION="${VERSION}" \
--build-arg BUILD_DATE="${BUILD_DATE}" \
--build-arg VCS_URL="${VCS_URL}" \
--build-arg VCS_REF="${VCS_REF}" \
--build-arg NAME="${NAME}" \
--build-arg VENDOR="${VENDOR}" \
-t alextanhongpin/hello-go .
run:
@docker run alextanhongpin/hello-go
label:
@docker inspect --format='{{json .Config.Labels}}' alextanhongpin/hello-go