-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
63 lines (45 loc) · 1.21 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
# Import .env file
ifneq (,$(wildcard ./.env))
include .env
export $(shell sed 's/=.*//' .env)
endif
# Variables
CONTAINER_NAME=${APP_NAME}-app
POSTGRES_CONTAINER_NAME=${APP_NAME}-db
# Commands
dep:
go mod tidy
run:
go run main.go
build:
go build -o main main.go
run-build: build
./main
test:
go test -v ./tests
init-docker:
docker compose up -d --build
up:
docker-compose up -d
down:
docker-compose down
logs:
docker-compose logs -f
# Postgres commands
container-postgres:
docker exec -it ${POSTGRES_CONTAINER_NAME} /bin/sh
create-db:
docker exec -it ${POSTGRES_CONTAINER_NAME} /bin/sh -c "createdb --username=${DB_USER} --owner=${DB_USER} ${DB_NAME}"
init-uuid:
docker exec -it ${POSTGRES_CONTAINER_NAME} /bin/sh -c "psql -U ${DB_USER} -d ${DB_NAME} -c 'CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\";'"
# Docker commands
container-go:
docker exec -it ${CONTAINER_NAME} /bin/sh
migrate:
docker exec -it ${CONTAINER_NAME} /bin/sh -c "go run main.go --migrate"
seed:
docker exec -it ${CONTAINER_NAME} /bin/sh -c "go run main.go --seed"
migrate-seed:
docker exec -it ${CONTAINER_NAME} /bin/sh -c "go run main.go --migrate --seed"
go-tidy:
docker exec -it ${CONTAINER_NAME} /bin/sh -c "go mod tidy"