-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
46 lines (35 loc) · 1.36 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
.PHONY: all help run test docker-compose-build-api docker-compose-up-api docker-compose-stop-api
RELEASE_VERSION := $(shell git rev-parse --short origin/master)
#RELEASE_VERSION := $(shell git describe) # describe last tag
all: help
## help: show this help message
help: Makefile
@echo
@echo " Choose a command to run in "${APP_NAME}":"
@echo
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo
## setup: get dependencies
setup:
GO111MODULE=on go mod download
## build: build the application to linux
build:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build --ldflags="-X 'main.Version=${RELEASE_VERSION}'" -o golang_api_skeleton main.go
## test: run unit tests
test:
go test -race -cover -failfast -count=1 ./...
## lint: lints the whole application code
lint:
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ${GOPATH}/bin v1.31.0
@golangci-lint run -E golint -e "(.*Sync|.*buf\.Write)"
## docker-compose-build-api: build application docker image
docker-compose-build-api:
@docker-compose build
## docker-compose-up-api: up application docker image
docker-compose-up-api:
@docker-compose up
## docker-compose-stop-api: stop application docker container
docker-compose-stop-api:
@docker-compose stop
## run: run application locally using docker
run: docker-compose-build-api docker-compose-up-api