-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (52 loc) · 1.41 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
60
61
62
63
64
65
66
67
# Go parameters
BINARY_NAME=go-project-template
BINARY_UNIX=$(BINARY_NAME)_unix
REPO=ghcr.io/dathan/go-project-template/go-project-template
.PHONY: all
all: lint test build
.PHONY: lint
lint:
golangci-lint run ./...
.PHONY: buildruntest
buildruntest: build build-linux customrun
.PHONY: customrun
customrun:
./scripts/customrun.sh
.PHONY: build
build:
go build -o ./bin ./cmd/...
.PHONY: test
test:
go test -p 6 -covermode=count -coverprofile=test/coverage.out test/*.go
.PHONY: clean
clean:
go clean
find . -type d -name '.tmp_*' -prune -exec rm -rvf {} \;
.PHONY: run
run:
go run ./cmd/$(BINARY_NAME)/*.go
.PHONY: vendor
vendor:
go mod vendor
# Cross compilation
.PHONY: build-linux
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/$(BINARY_UNIX) -v cmd/$(BINARY_NAME)/*.go
# Build docker containers
.PHONY: docker-build
docker-build:
# docker build \
# --build-arg GITHUB_SSH_PRIV_KEY="`cat ~/.ssh/id_rsa`" \
# -t $(or ${dockerImage},$(BINARY_NAME)-release) .
docker build \
-t $(or ${dockerImage},$(BINARY_NAME)-release) .
.PHONY: docker-tag
docker-tag:
docker tag `docker image ls --filter 'reference=$(BINARY_NAME)-release' -q` $(REPO):`git rev-parse HEAD`
# Push the container
.PHONY: docker-push
docker-push: docker-build docker-tag
docker push $(REPO):`git rev-parse HEAD`
.PHONY: docker-clean
docker-clean:
docker rmi `docker image ls --filter 'reference=$(BINARY_NAME)-*' -q`