-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (36 loc) · 1.51 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
SHELL := /bin/bash
BASEDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# Settings
PROJECT := life-captain
APPLICATION := $(PROJECT)-api
INFRASTRUCTURE := $(PROJECT)-database $(PROJECT)-database-migration
# Targets (application)
DOCKER_ENVIRONMENT := ENVIRONMENT=docker source ./scripts/environment.sh
DOCKER_COMPOSE := $(DOCKER_ENVIRONMENT) && docker compose -p $(PROJECT) -f $(BASEDIR)/scripts/docker/docker-compose.yml
DOCKER_VOLUMES := -v "$(BASEDIR)/src:/home/src" -v "$(BASEDIR)/tests:/home/__tests__" -v "$(BASEDIR)/prisma:/home/prisma"
build:
docker build . -t $(APPLICATION)
start:
$(DOCKER_COMPOSE) run $(APPLICATION) npm run start
start-dev:
$(DOCKER_COMPOSE) run $(DOCKER_VOLUMES) $(APPLICATION) npm run start-dev
start-infra:
$(DOCKER_COMPOSE) up $(INFRASTRUCTURE)
test:
$(DOCKER_COMPOSE) run $(DOCKER_VOLUMES) $(APPLICATION) npm run test
lint-type:
$(DOCKER_COMPOSE) run $(DOCKER_VOLUMES) $(APPLICATION) npm run lint-type
lint-code:
$(DOCKER_COMPOSE) run $(DOCKER_VOLUMES) $(APPLICATION) npm run lint-code
lint-style:
$(DOCKER_COMPOSE) run $(DOCKER_VOLUMES) $(APPLICATION) npm run lint-style
# Targets (database)
LOCAL_ENVIRONMENT := source ./scripts/environment.sh
PRISMA := $(LOCAL_ENVIRONMENT) && npx prisma
db-deploy:
$(PRISMA) migrate deploy
db-migrate:
read -r -p 'Migration name: ' migrationName && $(PRISMA) migrate dev --name "$migrationName"
db-explore:
$(PRISMA) studio
.PHONY: build start start-dev start-infra test lint-type lint-code lint-style db-deploy db-migrate db-explore