-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (62 loc) · 2.28 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
# ==================================================================================== #
# HELPERS
# ==================================================================================== #
.PHONY: confirm
confirm:
@echo -n 'Are you sure? [y/N] ' && read ans && [ $${ans:-N} = y ]
# ==================================================================================== #
# DEVELOPMENT
# ==================================================================================== #
migrate:
@echo "Applying migrations..."
migrate -path=./migrations -database=${DB_DSN} up
@echo "Migrations applied."
# DB_DSN='postgres://username:password@host/dbname'
# You can replace the placeholders (username, password, host, database name)
# with your actual database connection details and replace ${DB_DSN}
# - username: Your database username
# - password: Your database password
# - host: The host or address of your database server
# - dbname: The name of your database
# ==================================================================================== #
# PRODUCTION
# ==================================================================================== #
#Run the project locally
.PHONY: go/tidy
go/tidy:
go mod tidy
.PHONY: go/run
go/run:
go run ./cmd/api
.PHONY: setup
setup: confirm go/tidy go/run migrate
# Build the containers using the configuration in docker-compose.yaml
docker/build:
docker compose build
# Start the containers using the configuration in docker-compose.yaml
docker/run: confirm
docker compose up -d
# Stop the containers
docker/stop: confirm
docker compose down
# ==================================================================================== #
# QUALITY CONTROL
# ==================================================================================== #
# audit: tidy dependencies and format, vet and test all code
.PHONY: audit
audit: vendor
@echo 'Formatting code...'
go fmt ./...
@echo 'Vetting code...'
go vet ./...
staticcheck ./...
@echo 'Running tests...'
go test -race -vet=off ./...
# vendor: tidy and vendor dependencies
.PHONY: vendor
vendor:
@echo 'Tidying and verifying module dependencies...'
go mod tidy -compat=1.17
go mod verify
@echo 'Vendoring dependencies...'
go mod vendor