-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (53 loc) · 1.42 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
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
base_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
# Golang project related settings
GO?=go
APP?=$(base_dir)
APP_NAME=my-app
APP_DIR=app
CLI_NAME=$(APP)-cli
CLI_DIR=cli
PROJECT_PACKAGE=github.com/lucassouzavieira/$(APP)
WORK_DIR=/go/src/$(PROJECT_PACKAGE)
BUILD_DIRECTORY=build
LINTER_EXECUTABLE := golangci-lint
LINTER_PATH := $(GOPATH)/bin/$(LINTER_EXECUTABLE)
GOFMT := gofmt
BUILD_ENV :=
BUILD_ENV += CGO_ENABLED=0
# Docker
DOCKER_REPOSITORY=localhost
DOCKER_IMAGE=$(APP)
DOCKER_TAG=1.0
DOCKER_NAMESPACE=localns
DOCKER_IMAGE_NAME=$(DOCKER_NAMESPACE)/$(DOCKER_IMAGE)
DOCKER_BUILD_ENV :=
DOCKER_BUILD_ENV += --log-level=debug --platform=linux/amd64 --rm
# Make commands
.PHONY: build
build:
$(BUILD_ENV) go build -o build/$(APP_NAME) -a ./cmd/$(APP_DIR)
build-cli:
$(BUILD_ENV) go build -o build/$(CLI_NAME) -a ./cmd/$(CLI_DIR)
docker-build:
docker build $(DOCKER_BUILD_ENV) -t $(DOCKER_IMAGE_NAME):$(DOCKER_TAG) .
proto:
protoc --go_out=:. --go-grpc_out=:. internal/protobuf/schema/*.proto
.PHONY: lint
lint:
$(LINTER_PATH) run ./...
.PHONY: fmt
fmt:
$(GOFMT) -s -w .
test:
$(GO) test -v -cover -timeout 3m ./...
# Utilitary commands
install-tools:
go get github.com/google/wire/cmd/wire
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2
.PHONY: init
init:
rm -f go.mod go.sum
go mod init $(PROJECT_PACKAGE)
go mod tidy
make install-tools