-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
129 lines (89 loc) · 3.54 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
include .env
.DEFAULT_GOAL:=help
PWD=$(shell pwd)
COMPOSE=docker compose
EXECAPI=$(COMPOSE) exec api
EXECPG=$(COMPOSE) exec postgres
## All commands available in the Makefile
##@ Helper
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nAll commands available in the Makefile\n \nUsage:\n make \033[36m<target>\033[0m\n"} /^[.a-zA-Z_-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Starting/stopping the project
start: build up-recreate ## Build and start containers project
build: ## Build containers project
$(COMPOSE) build --force-rm
up: ## Start the project
$(COMPOSE) up -d --remove-orphans
up-recreate: ## Start the project and recreate the containers
$(COMPOSE) up -d --remove-orphans --force-recreate
stop: ## Stop containers project
$(COMPOSE) stop
down: ## Stop and remove containers project
$(COMPOSE) down
restart: ## Restart containers project
$(COMPOSE) restart
##@ SSH
ssh: ## SSH into the next container
$(EXECAPI) sh
ssh-pg: ## SSH into the postgres container
$(EXECPG) bash
##@ Golang
tidy: ## Run go mod tidy
$(EXECAPI) go mod tidy
lint: ## Run golangci-lint
$(EXECAPI) golangci-lint run -v
##@ Containers
list-containers: ## List all containers
docker compose ps -a
##@ Logs
logs: ## Show logs
$(COMPOSE) logs
logs-api: ## Show logs for the next container
$(COMPOSE) logs --since 1m -f api
logs-pg: ## Show logs for the postgres container
$(COMPOSE) logs postgres
##@ Dart
lint-dart: ## Run dart lint
cd mobile && flutter analyze --suppress-analytics --no-fatal-infos
dart-build-runner: ## Run build_runner
cd mobile && dart run build_runner build --delete-conflicting-outputs
dart-build-runner-watch: ## Run build_runner watch
cd mobile && dart run build_runner watch --delete-conflicting-outputs
##@ Database
db-reset: db-drop db-create dma fixtures ## Reset the database
db-drop-dev: ## Drop the dev database (use only if db-create-migration fails)
$(EXECPG) dropdb dev
db-create-migration: ## Create a new migration
$(EXECPG) createdb dev
$(EXECAPI) atlas migrate diff --env gorm
$(EXECPG) dropdb dev
dcm: db-create-migration ## Alias for db-create-migration
db-migrate-apply: ## Apply the migrations
$(EXECAPI) atlas migrate apply --dir "file://migrations" --url ${DB_URL} --allow-dirty
db-m-a:
docker run --rm -v $(PWD)/api/migrations:/migrations --network for-democracy_default arigaio/atlas migrate apply --dir "file://migrations" --url ${DB_URL} --allow-dirty
dma: db-migrate-apply ## Alias for db-migrate-apply
db-create-empty-migration: ## Create an empty migration
$(EXECAPI) atlas migrate new --dir "file://migrations"
dcem: db-create-empty-migration ## Alias for db-create-empty-migration
db-hash: ## Generate the hash for the migration
$(EXECAPI) atlas migrate hash
db-drop: ## Drop the database
$(EXECPG) dropdb ${DB_NAME} --force
db-create: ## Create the database
$(EXECPG) createdb ${DB_NAME}
##@ Swagger
swagger: ## Generate swagger documentation
$(EXECAPI) swag init --parseDependency --parseInternal
##@ CLI
collector: ## Collect the data from the API and store it in the database
$(EXECAPI) go run main.go collector
events: ## Collect the events from the API and store it in the database
$(EXECAPI) go run main.go collector-events
example: ## Run the example commande
$(EXECAPI) go run main.go example
cron: ## Run the cron job to collect events
$(EXECAPI) go run main.go cron
fixtures: ## Run the admin fixtures
$(EXECAPI) go run main.go adminFixtures
$(EXECAPI) go run main.go featureFixtures