-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
71 lines (60 loc) · 1.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
GO ?= go
GOFMT ?= gofmt "-s"
GOFILES := $(shell find . -name "*.go")
CURRENT_DIR = $(shell pwd)
SERVER_DIR = cd server/
CLIENT_DIR = cd client/
DOCKER ?= docker
.PHONY: air
# Install air for live-reload.
air:
@mkdir -p bin
@GOBIN=$(CURRENT_DIR)/$(SERVER_DIR)/bin $(GO) install github.com/air-verse/air@latest
.PHONY: dev
# Run the application in watch mode.
dev:
@$(CURRENT_DIR)/bin/air
.PHONY: build
# Build the client.
build:
@$(CLIENT_DIR) && npm run build
.PHONY: run
# Run the application.
run:
@$(SERVER_DIR) && $(GO) run .
.PHONY: up
# Start the containers.
up:
@$(DOCKER) compose up -d
.PHONY: down
# Stop the containers.
down:
@$(DOCKER) compose down
.PHONY: enter
# Enter the database.
enter:
@$(DOCKER) exec -it gin-postgres psql -d gin-postgres -U demystif -W
.PHONY: tidy
# Tidy the Go module.
tidy:
@$(SERVER_DIR) && $(GO) mod tidy
.PHONY: fmt
# Format the Go files.
fmt:
@$(SERVER_DIR) && $(GOFMT) -w $(GOFILES)
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf " - \033[36m%-20s\033[0m %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help