-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (48 loc) · 1.62 KB
/
Copy pathMakefile
File metadata and controls
57 lines (48 loc) · 1.62 KB
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
.DEFAULT_GOAL := help
############################
## Project Info
############################
PROJECT = gort
GIT_URL = github.com
GIT_ORGANIZATION = getgort
GIT_REPOSITORY = $(GIT_URL)/$(GIT_ORGANIZATION)/$(PROJECT)
############################
## Docker Registry Info
############################
REGISTRY_URL = getgort
IMAGE_NAME = $(REGISTRY_URL)/$(PROJECT)
IMAGE_TAG = $(shell grep "Version =" version/version.go | sed 's/.*Version = "\(.*\)"/\1/')
help:
# Commands:
# make help - Show this message
#
# Dev commands:
# make clean - Remove generated files
# make test - Run Go tests
# make build - Build go binary
#
# Docker commands:
# make image - Build Docker image with current version tag
# make run - Run Docker image with current version tag
#
# Deployment commands:
# make push - Push current version tag to registry
clean:
if [ -d "bin" ]; then rm -R bin; fi
rm -f coverage.out coverage.html
test:
@DOCKER_BUILDKIT=1 docker build --target test -t foo_$(PROJECT)_foo --network host .
@docker rmi foo_$(PROJECT)_foo
test-local:
@go test -count=1 -timeout 60s -cover -race -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
build: clean
mkdir -p bin
@go build -a -installsuffix cgo -o bin/$(PROJECT) $(GIT_REPOSITORY)
image: test
@echo Building image $(IMAGE_NAME):$(IMAGE_TAG)
@DOCKER_BUILDKIT=1 docker build --target image -t $(IMAGE_NAME):latest --network host .
@docker tag $(IMAGE_NAME):latest $(IMAGE_NAME):$(IMAGE_TAG)
push: image
@docker push $(IMAGE_NAME):$(IMAGE_TAG)
@docker push $(IMAGE_NAME):latest