-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
135 lines (107 loc) · 3.77 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
130
131
132
133
134
135
SHELL := /bin/bash
# requires Docker Compose version v2.2.1+
GAR := northamerica-northeast2-docker.pkg.dev/project-ct-beta/project-ct-beta-gar/
all:
@echo "Starting project application..."
@docker compose up -d web
api:
@echo "Starting api..."
@docker compose up -d api
testapi:
@echo "Running api unit tests..."
@docker compose up testapi --exit-code-from testapi
seed:
@echo "Seeding database..."
@docker compose up seeder --exit-code-from seeder
db:
@echo "Starting db..."
@docker compose up -d db
web:
@echo "Starting frontend and api..."
@docker compose up -d web
mig:
@echo "Creating database and applying migrations for medical..."
@docker compose up migs
mig-sanctuary:
@echo "Creating database and applying migrations for sanctuary..."
@docker compose up migssanctuary
automig:
@echo "Autogenerating migration in docker context"
@docker compose up -d --no-recreate api
@docker compose exec api bash -c "cd /app/api && alembic --name medical revision --autogenerate -m 'CHANGEME'"
automig-sanctuary:
@echo "Autogenerating migration in docker context"
@docker compose up -d --no-recreate api
@docker compose exec api bash -c "cd /app/api && alembic --name sanctuary revision --autogenerate -m 'CHANGEME'"
prune:
@echo "Pruning docker artifacts..."
@docker system prune -a
env:
@echo "Setting up default env"
@cp app/api/.env-example app/api/.env
@cp app/web/.env-example app/web/.env.local
deploymig:
@echo "..."
@echo "Applying migrations to CloudSQL database..."
@cp app/api/.env app/api/.env.bkup
@cp app/api/.env.prod app/api/.env
@docker compose up --build migsprod
@cp app/api/.env.bkup app/api/.env
stop:
@echo "Stopping containers..."
@docker compose down
clean: stop |
@echo "Cleaning up all container artifacts..."
@docker system prune -f -a --volumes
@echo "Deleting thicc node_modules"
@rm -rf app/web/node_modules
@echo "Deleting .next build artifacts"
@rm -rf app/web/.next
test-web:
@echo "Running web tests..."
cd app/web && yarn test
#PRODUCTION IMAGE VERIFICATION
allprod:
@echo "Starting production project application..."
@docker compose up -d webtarget
apiprod:
@echo "Starting prod api..."
@docker compose up -d apitarget
testapiprod:
@echo "Running prod api unit tests..."
@docker compose up testapitarget --exit-code-from testapitarget
webprod:
@echo "Starting prod frontend and api..."
@docker compose up -d webtarget
migsprod:
@echo "Creating database and applying migrations..."
@docker compose up migstarget
#BUILD AND PUSH FUNCTIONALITY
#REQUIRES USER TO BE AUTHENTICATED TO USE THE GCLOUD ARTIFACT RESPOSITORY
#https://cloud.google.com/artifact-registry/docs/docker/store-docker-container-images
build-push-api:
ifeq ($(filter-out build-push-api, $(MAKECMDGOALS)),)
@echo "Please provide an image tag to push e.g. 'make build-push-api <imagetag>'"
else
ifeq ($(filter-out build-push-api, $(MAKECMDGOALS)), prod) #production image build and push
@docker build -f app/api/Dockerfile.prod app/api -t $(GAR)api:prod
@docker push $(GAR)api:prod
else #any other tags, use dev build dockerfile image
@docker build -f app/api/Dockerfile.dev app/api -t $(GAR)api:$(filter-out $@, $(MAKECMDGOALS))
@docker push $(GAR)api:$(filter-out $@, $(MAKECMDGOALS))
endif
endif
build-push-web:
ifeq ($(filter-out build-push-web, $(MAKECMDGOALS)),)
@echo "Please provide an image tag to push: e.g. 'make build-push-web <imagetag>'"
else
ifeq ($(filter-out build-push-web, $(MAKECMDGOALS)), prod) #production image build and push
@docker build -f app/web/Dockerfile.prod app/web -t $(GAR)web:prod
@docker push $(GAR)web:prod
else # any other tags, use dev build dockerfile image
@docker build -f app/web/Dockerfile.dev app/web -t $(GAR)web:$(filter-out $@, $(MAKECMDGOALS))
@docker push $(GAR)web:$(filter-out $@, $(MAKECMDGOALS))
endif
endif
%:
@: