-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
100 lines (75 loc) · 3.02 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
.DEFAULT_GOAL := help
# HOST is only used for API specs generation
HOST ?= localhost:8080
# Generates a help message. Borrowed from https://github.com/pydanny/cookiecutter-djangopackage.
help: ## Display this help message
@echo "Please use \`make <target>' where <target> is one of"
@perl -nle'print $& if m{^[\.a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}'
depends: ## Install & build dependencies
go get ./...
go build ./...
go mod tidy
provision: depends ## Provision dev environment
docker-compose up -d
scripts/waitdb.sh
@$(MAKE) migrate
dev: ## Bring up the server on dev environment with hot reload
docker-compose up -d
sh scripts/waitdb.sh
air
remove: ## Bring down the server on dev environment, remove all docker related stuffs as well
docker-compose down -v --remove-orphans
migrate: ## Run database migrations
go run cmd/migration/main.go
migrate.undo: ## Undo the last database migration
go run cmd/migration/main.go --down
seed: ## Run database seeder
echo "To be done!"
test: ## Run tests
sh scripts/test.sh
test.cover: test ## Run tests and open coverage statistics page
go tool cover -html=coverage-all.out
build: clean ## Build the server binary file on host machine
sh scripts/build.sh
build.linux: ## Build the server binary file for Linux host
@$(MAKE) GOOS=linux GOARCH=amd64 build
build.windows: ## Build the server binary file for Windows host
@$(MAKE) GOOS=windows GOARCH=amd64 build
build.arm: clean ## Build the server binary file for ARM host
GOOS=linux GOARCH=arm64 sh scripts/build-arm.sh
build.air: ## Build the server binary file for air hot reload
sh scripts/build-air.sh
install:
echo "Not ready yet!"
echo "To setup PostgreSQL, check 'scripts/install-pg.sh'"
echo "To setup the server, check 'scripts/install-service.sh'"
clean: ## Clean up the built & test files
rm -rf ./server ./*.out
specs: ## Generate swagger specs
swag fmt -g /cmd/api/main.go
swag fmt -d ./internal/api
swag init --parseInternal --parseDependency --parseDepth 1 -g /cmd/api/main.go
up: ## Execute `up` commands per env. Ex: make up dev "logs -f"
sh scripts/up.sh $(filter-out $@,$(MAKECMDGOALS))
dev.deploy: ## Deploy to DEV environment
scripts/apex.sh dev deploy --alias dev
scripts/apex.sh dev invoke --alias dev migration
scripts/up.sh dev deploy dev
demo.deploy: ## Deploy to DEMO environment
scripts/apex.sh dev deploy --alias demo
scripts/apex.sh dev invoke --alias demo migration
scripts/up.sh dev deploy demo
stg.deploy: ## Deploy to STAGING environment
scripts/apex.sh client deploy --alias staging
scripts/apex.sh client invoke --alias staging migration
scripts/up.sh client deploy staging
prod.deploy: ## Deploy to PROD environment
scripts/apex.sh client deploy --alias production
scripts/apex.sh client invoke --alias production migration
scripts/up.sh client deploy production
%: # prevent error for `up` target when passing arguments
ifeq ($(filter up,$(MAKECMDGOALS)),up)
@:
else
$(error No rule to make target `$@`.)
endif