-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (67 loc) · 1.74 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
MIGRATION_PATH = ./cmd/migrate/migrations
DB_URL = postgres://admin:adminpassword@localhost/social?sslmode=disable
#############
# APP
#############
# Build the app
run-app:
@docker-compose up --build
.PHONY: run-app
# Stop the app
stop-app:
@docker-compose down
.PHONY: stop-app
#############
# Migrations
#############
# Fix for Dirty migration version 3. Fix and force version.
fix-migration:
@migrate -path $(MIGRATION_PATH) -database $(DB_URL) force 3
.PHONY: fix-migration
# Create a new migration
create-migration:
@migrate create -seq -ext sql -dir $(MIGRATION_PATH) $(filter-out $@,$(MAKECMDGOALS))
.PHONY: create-migration
# Run the migrations
migrate-up:
@migrate -path $(MIGRATION_PATH) -database $(DB_URL) up
.PHONY: migrate-up
# Rollback the migrations
migrate-down:
@migrate -path $(MIGRATION_PATH) -database $(DB_URL) down $(filter-out $@,$(MAKECMDGOALS))
.PHONY: migrate-down
#############
# Server
#############
# Build the server
build-server:
@go build -o bin/main cmd/api/*.go
.PHONY: build-server
# Run the server
run-server:
@go run cmd/api/*.go
.PHONY: run-server
# Run the server with hot reload
run-dev-server:
@go run github.com/air-verse/[email protected] \
--build.bin "./bin/main" \
--build.cmd "make build-server" \
--build.delay "100" \
--build.exclude_dir "assets, bin, vender, testdata, docs, scripts" \
--build.exclude_regex "*\\_test\\.go" \
--build.include_ext "go, tpl, tmpl, html, css, xml, yaml, yml, json" \
--build.log "build-errors.log" \
--color.app "blue" \
--color.build "yellow" \
--color.main "magenta" \
--color.runner "green" \
--color.watcher "cyan" \
--misc.clean_on_exit "true" \
.PHONY: run-dev-server
#############
# Utils
#############
# Format the code
fmt:
@go fmt ./...
.PHONY: fmt