-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (36 loc) · 1.13 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
# environment variables
dns ?= postgres://$(DB_USER):$(DB_PASSWORD)@$(DB_HOST):$(DB_PORT)/$(DB_NAME)?sslmode=$(DB_SSL_MODE)
# migration path
migrationPath ?= ./internal/database/migrations
# loading .env
include .env
export $(shell sed 's/=.*//' .env)
# targets
.PHONY: run build seed db-status db-up db-down run-dev
run: build
@./bin/main
build:
@go build -o bin/main cmd/main.go
seed:
@go run cmd/seed.go
db-status:
@GOOSE_DRIVER=postgres GOOSE_DBSTRING=$(dns) goose -dir=$(migrationPath) status
db-up:
@GOOSE_DRIVER=postgres GOOSE_DBSTRING=$(dns) goose -dir=$(migrationPath) up
db-down:
@GOOSE_DRIVER=postgres GOOSE_DBSTRING=$(dns) goose -dir=$(migrationPath) down
run-dev:
@air
clear:
@rm -rf bin
# helper targets
.PHONY: help
help:
@echo "make run - run the application"
@echo "make build - build the application"
@echo "make seed - seed the database"
@echo "make db-status - check the database status"
@echo "make db-up - migrate the database up"
@echo "make db-down - migrate the database down"
@echo "make run-dev - run the application in development mode"
@echo "make clear - clear the application's bin directory"