-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
59 lines (39 loc) · 1.37 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Assumption for some targets is that golang 1.9+ is already installed
# Switch default shell to be bash
SHELL=/bin/bash
# Parameters - defaulted
DOCKERHUB_REPO_NAME ?= ${USER}
IMAGE_NAME ?= eatr
VERSION ?= $(shell cat VERSION)
# Derived or calculated
BUILD_DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
FULL_IMAGE_NAME = ${DOCKERHUB_REPO_NAME}/${IMAGE_NAME}
FULL_IMAGE_TAG_NAME = ${FULL_IMAGE_NAME}:${VERSION}
REPO_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
REPO_VERSION = $(shell git rev-parse HEAD)
default: build
ensure-deps:
[[ -z "$(which dep)" ]] && go get -u github.com/golang/dep/cmd/dep
dep ensure -v
build-with-deps: ensure-deps build
build:
@# Fast build - so we can run without having to wait for full static build
go build -ldflags "-X main.version=${VERSION} -X main.repoBranch=${REPO_BRANCH} -X main.repoVersion=${REPO_VERSION}" .
test:
go test -v ./...
build-static:
CGO_ENABLED=0 GOOS=linux go build \
-a \
-installsuffix cgo \
-o eatr \
-ldflags "-X main.version=${VERSION} -X main.repoBranch=${REPO_BRANCH} -X main.repoVersion=${REPO_VERSION}" \
.
image:
@echo '** NOTE This can take about 10 minutes, be patient'
docker image build \
--build-arg BUILD_DATE=${BUILD_DATE} \
--build-arg REPO_BRANCH=${REPO_BRANCH} \
--build-arg REPO_VERSION=${REPO_VERSION} \
--build-arg VERSION=${VERSION} \
--tag ${FULL_IMAGE_TAG_NAME} \
.