-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (74 loc) · 2.35 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
#
# dish / Makefile
#
#
# vars
#
include .env.example
-include .env
PROJECT_NAME?=${APP_NAME}
DOCKER_DEV_IMAGE?=${PROJECT_NAME}-image
DOCKER_DEV_CONTAINER?=${PROJECT_NAME}-run
COMPOSE_FILE=deployments/docker-compose.yml
# define standard colors
# https://gist.github.com/rsperl/d2dfe88a520968fbc1f49db0a29345b9
ifneq (,$(findstring xterm,${TERM}))
BLACK := $(shell tput -Txterm setaf 0)
RED := $(shell tput -Txterm setaf 1)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
LIGHTPURPLE := $(shell tput -Txterm setaf 4)
PURPLE := $(shell tput -Txterm setaf 5)
BLUE := $(shell tput -Txterm setaf 6)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
else
BLACK := ""
RED := ""
GREEN := ""
YELLOW := ""
LIGHTPURPLE := ""
PURPLE := ""
BLUE := ""
WHITE := ""
RESET := ""
endif
export
#
# targets
#
all: info
.PHONY: info
info:
@echo -e "\n${GREEN} ${PROJECT_NAME} / Makefile ${RESET}\n"
@echo -e "${YELLOW} make fmt --- reformat the go source (gofmt) ${RESET}"
@echo -e "${YELLOW} make test --- run unit tests (go test) ${RESET}"
@echo -e "${YELLOW} make build --- build project (docker image) ${RESET}"
@echo -e "${YELLOW} make run --- run project ${RESET}"
@echo -e "${YELLOW} make logs --- fetch container's logs ${RESET}"
@echo -e "${YELLOW} make stop --- stop and purge project (only docker containers!) ${RESET}\n"
.PHONY: build
build:
@echo -e "\n${YELLOW} Building project (docker-compose build)... ${RESET}\n"
@docker compose -f ${COMPOSE_FILE} build
.PHONY: local_build
local_build:
@echo -e "\n${YELLOW} [local] Building project... ${RESET}\n"
@go mod tidy
@go build -tags dev -o dish cmd/dish/main.go
.PHONY: run
run: build
@echo -e "\n${YELLOW} Starting project (docker-compose up)... ${RESET}\n"
@docker compose -f ${COMPOSE_FILE} up --force-recreate
.PHONY: logs
logs:
@echo -e "\n${YELLOW} Fetching container's logs (CTRL-C to exit)... ${RESET}\n"
@docker logs ${DOCKER_DEV_CONTAINER} -f
.PHONY: stop
stop:
@echo -e "\n${YELLOW} Stopping and purging project (docker-compose down)... ${RESET}\n"
@docker compose -f ${COMPOSE_FILE} down
.PHONY: test
test:
@echo -e "\n${YELLOW} [local] Running unit tests (go test)... ${RESET}\n"
@go test ./...