-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (44 loc) · 1.72 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
# imports env vars
include .env
# .PHONY for targets will prevent make from confusing the phony target with a file name
.PHONY: = dev nuke prune_img prune_sys prune_vols remove_api stop
dev: ## run dev api & database in docker
docker compose up dev
space := $(subst ,, )
ifeq (new_migration,$(firstword $(MAKECMDGOALS)))
MIGRATE_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(MIGRATE_ARGS):;@:)
endif
NAME := $(subst $(space),_,$(MIGRATE_ARGS))
new_migration: ## runs knex migrations:make command; pass migration name after make command, no quotes
npm run migrate:make $(NAME)
migrate:
DATABASE_URL=${DATABASE_URL} npm run migrate
nuke: # wipes out dev environment
make stop
make remove_api
make prune_sys
make prune_vols
make dev
prod: ## run local production api & database in docker
docker compose up api-local-prod
prune_img: ## run docker prune on all stopped/not in use images
docker image prune
prune_sys: ## run docker prune for system (stopped containers, dead networks, unused images, build cache)
docker system prune
prune_vols: ## run docker prune for volumes not in use by a container
docker volume prune
remove_api: ## delete docker API image, by reference & formatting to pass ID into rmi cmd
@docker rmi --force $$(docker images --filter=reference="groovebase-api-dev" --format="{{.ID}}")
seed_dev: ## run seeder for dev environment
DATABASE_URL=${DATABASE_URL} knex seed:run
seed_prod: ## run seeder for dev environment
DATABASE_URL=${DATABASE_URL} knex seed:run
setup_local_db: ## run migrations and seeds for local database
make migrate_dev
make seed_dev
setup_prod_db: ## run migrations and seeds for prod database
make migrate_prod
make seed_prod
stop:
docker compose down