-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
88 lines (68 loc) · 1.81 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
APP?=go-admin
REGISTRY?='private-registry'
COMMIT_SHA=$(shell git rev-parse --short HEAD)
.PHONY: build
## build: build the application
build: clean
@echo "Building..."
@go build -o ${APP} main.go
.PHONY: run
## run: runs the go run build-binary
run: build
./go-admin
.PHONY: watch
## watch: watch the project for go file changes
watch:
ulimit -n 1000
reflex -s -r '\.go$$' make run
.PHONY: clean
## clean: cleans the binary
clean:
@echo "Cleaning..."
@go clean
.PHONY: test
## test: runs go test with default values
test:
go test -v -count=1 -race ./...
.PHONY: setup
## setup: setup go modules
setup:
@go mod init \
&& go mod tidy \
&& go mod vendor
## helper rule for deployment
check-environment:
ifndef ENV
${error ENV not set, allowed values - `staging` or `production`}
endif
.PHONY: db-up
## db-up: start mysql and phpadmin
db-up:
docker container start mysql phpmyadmin
.PHONY: db-down
## db-down: stop mysql and phpadmin
db-down:
docker container stop mysql phpmyadmin
.PHONY: docker-build
## docker-build: builds the boolang docker image to registry
docker-build: build
docker build -t ${APP} .
docker tag ${APP} ${APP}:${COMMIT_SHA}
.PHONY: docker-push
## docker-push: pushes the boolang docker image to registry
docker-push: docker-build
docker push ${REGISTRY}/${ENV}/${APP}:${COMMIT_SHA}
.PHONY: docker-compose-up
## docker-compose-up: to spin up multiple services
docker-compose-up:
docker-compose -f docker/dev/docker-compose.yml up --build
.PHONY: docker-compose-down
## docker-compose-down: to stop and remove unwanted image builds
docker-compose-down:
docker-compose -f docker/dev/docker-compose.yml down
docker system prune --volumes --force
.PHONY: help
## help: prints this help message
help:
@echo "Usage: \n"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'