-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
56 lines (40 loc) · 1.46 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
# Passed into main.go at build time
VERSION := $(shell cat ./VERSION)
COMMIT_HASH := $(shell git rev-parse HEAD)
BUILD_TIME := $(shell date +%s)
# Used in tagging images
IMAGE_VERSION_TAG := victims-bot:$(VERSION)
IMAGE_DATE_TAG := victims-bot:$(BUILD_TIME)
PACKAGES := process/ cmd/ log/ web/
# Used during all builds
LDFLAGS := -X main.version=${VERSION} -X main.commitHash=${COMMIT_HASH} -X main.buildTime=${BUILD_TIME}
.PHONY: help clean victims-bot image
default: help
help:
@echo "Targets:"
@echo " deps: Install dependencies with govendor"
@echo " victims-bot: Builds a victims-bot binary"
@echo " clean: cleans up and removes built files"
@echo " image: builds a container image"
deps:
go get github.com/kardianos/govendor
govendor sync
victims-bot:
govendor build -ldflags '${LDFLAGS}' -o victims-bot main.go
static-victims-bot:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 govendor build --ldflags '-extldflags "-static" ${LDFLAGS}' -a -o victims-bot main.go
clean:
go clean
rm -f victims-bot
image: clean deps static-victims-bot
sudo docker build -t $(IMAGE_VERSION_TAG) -t $(IMAGE_DATE_TAG) .
autobuild: clean
sudo docker build -t release -t $(IMAGE_DATE_TAG) -f Dockerfile.autobuild .
test: clean deps
govendor test -v -cover github.com/victims/victims-bot/process github.com/victims/victims-bot/cmd github.com/victims/victims-bot/web
gofmt:
gofmt -l ${PACKAGES} main.go
golint:
go get github.com/golang/lint/golint
golint ${PACKAGES}
lint: gofmt golint