-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (42 loc) · 1.76 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
.PHONY: help env build build-local up down logs ps test generate migrate
.DEFAULT_GOAL := help
env: ## Initialize project
cp example.env .env
DOCKER_TAG := latest
build: ## Build docker image to deploy
docker build -t geekcamp-vol11-team30/backend:${DOCKER_TAG} \
--target deploy ./
build-local: ## Build docker image to local development
docker compose build --no-cache
up: ## Do docker compose up with hot reload
docker compose up -d
down: ## Do docker compose down
docker compose down
init-local: ## Initialize local development
@make env
@make build-local
@make up
@make migrate
logs: ## Tail docker compose logs
docker compose logs -f
ps: ## Check container status
docker compose ps
exec: ## Execute command in container
docker compose exec -it app bash
exec-db: ## Execute command in container
docker compose exec -it db mysql -umysql -pmysql magische
test: ## Execute tests
docker compose exec -it app go test -race -shuffle=on ./... -coverprofile=coverage.out
generate: ## Go generate
rm -rf ./repository/internal/models
docker compose exec -it app go generate ./...
migrate: ## Execute migration
docker compose exec -it app goose -dir ./db/migrations mysql "mysql:mysql@tcp(db:3306)/magische?parseTime=true&multiStatements=true" up
migrate-down: ## Execute migration
docker compose exec -it app goose -dir ./db/migrations mysql "mysql:mysql@tcp(db:3306)/magische?parseTime=true&multiStatements=true" down
migrate-remote: ## Execute migration on remote
docker build --target migrate -t geekcamp-vol11-team30/backend-migrate:${DOCKER_TAG} .
docker run geekcamp-vol11-team30/backend-migrate:${DOCKER_TAG}
help: ## Show options
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'