-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
42 lines (33 loc) · 1.06 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
branch = $(shell git rev-parse --abbrev-ref HEAD)
commit = $(shell git log --pretty=format:'%H' -n 1)
now = $(shell date "+%Y-%m-%d %T UTC%z")
compiler = $(shell go version)
IMAGE_NAME := thetreep/toolbox
all: test build image
test:
@echo "Running tests"
@docker-compose -f docker-compose.test.yml up \
--build \
--abort-on-container-exit \
--force-recreate \
--quiet-pull \
--no-color \
--remove-orphans \
--timeout 20
@docker-compose -f docker-compose.test.yml down
@docker-compose -f docker-compose.test.yml rm -f
build:
@echo "Compiling the binaries"
CGO_ENABLED=0 \
GOBIN=$(PWD)/bin \
go install -v \
-ldflags \
"-X 'main.branch=$(branch)' \
-X 'main.sha=$(commit)' \
-X 'main.compiledAt=$(now)' \
-X 'main.compiler=$(compiler)' \
-s -w" \
-a -installsuffix cgo ./...
image:
@(echo "Building $(IMAGE_NAME) Docker Image")
@(docker build -f Dockerfile -t $(IMAGE_NAME) .)