forked from MaoDeMatos/gofiber-mongo-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (38 loc) · 1.24 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
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
# Variables
BUILD_PATH = ./tmp
MONGO_CONTAINER_NAME = mongodb
.PHONY: install
install: ## Install dependencies and setup .env file
@echo ⬇️ Download project dependencies
go mod download
@echo ⬇️ Download air
go install github.com/cosmtrek/air@latest
@echo 📄 Create .env
@cp .env.sample .env
.PHONY: dev
dev: ## Run in Development mode
air
.PHONY: build
build: ## Build for Production
go build -o ${BUILD_PATH}/main ./cmd/api
.PHONY: start
start: ## Run Production build
${BUILD_PATH}/main
.PHONY: clear
clear: ## Clear generated files
rm -rf ${BUILD_PATH}
.PHONY: db-create
db-create: ## Create MongdoDB Docker container
docker run -d --name ${MONGO_CONTAINER_NAME} -v mongodb-volume:/data/db -v mongodb-volume:/data/configdb -p 27017:27017 mongo:latest
.PHONY: db-start
db-start: ## Start MongdoDB container
docker start ${MONGO_CONTAINER_NAME}
.PHONY: db-stop
db-stop: ## Stop MongdoDB container
docker stop ${MONGO_CONTAINER_NAME}
# Self-Documenting part
.PHONY: help
.DEFAULT_GOAL := help
help:
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "-> \033[36m%-20s\033[0m %s\n", $$1, $$2}'