-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
112 lines (92 loc) · 2.98 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
PROJECT_NAME = "esd"
LOCAL_DEPLOY_DIR = "deployment/docker"
NPM_SUBDIRS = backend/simple/user-storage client
npm-install:
@echo "Running npm install to set up Husky and other dependencies..."
@if [ ! -d "node_modules" ]; then \
npm install; \
fi
@echo "All npm dependencies installed."
# ---------------------------------------
# For deploying docker containers locally
# ---------------------------------------
dev/up: npm-install
@docker compose -p ${PROJECT_NAME} \
-f ${LOCAL_DEPLOY_DIR}/docker-compose.yml \
up --build -d --remove-orphans
dev/nobuild/up: npm-install
@docker-compose -p ${PROJECT_NAME} \
-f ${LOCAL_DEPLOY_DIR}/docker-compose.yml \
up -d
up: npm-install
@docker compose -p ${PROJECT_NAME} \
-f ${LOCAL_DEPLOY_DIR}/docker-compose.submission.yml \
up --build -d --remove-orphans
nobuild/up: npm-install
@docker-compose -p ${PROJECT_NAME} \
-f ${LOCAL_DEPLOY_DIR}/docker-compose.submission.yml \
up -d
# ---------------------------------
# For tearing down local deployment
# ---------------------------------
dev/down:
@docker compose -p ${PROJECT_NAME} \
-f ${LOCAL_DEPLOY_DIR}/docker-compose.yml \
down
dev/down-clean:
@echo "Taking down services and removing volumes..."
@docker compose -p ${PROJECT_NAME} \
-f ${LOCAL_DEPLOY_DIR}/docker-compose.yml \
down --volumes --remove-orphans
@$(MAKE) prune-esd-images
down:
@docker compose -p ${PROJECT_NAME} \
-f ${LOCAL_DEPLOY_DIR}/docker-compose.submission.yml \
down
down-clean:
@echo "Taking down services and removing volumes..."
@docker compose -p ${PROJECT_NAME} \
-f ${LOCAL_DEPLOY_DIR}/docker-compose.submission.yml \
down --volumes --remove-orphans
@$(MAKE) prune-esd-images
prune-all:
@echo "Running this command will prune all images. Do you want to proceed [y/N]?"; \
read ans; \
case "$$ans" in \
[Yy]*) docker image prune -a -f ;; \
*) echo "Aborting." ;; \
esac
prune-esd-images:
@echo "This will remove all unused images associated with the esd project. Continue? [y/N]"; \
read ans; \
if [ "$$ans" = "y" ] || [ "$$ans" = "Y" ]; then \
docker images | grep 'esd' | awk '{print $$3}' | xargs -r docker rmi -f || echo "No esd related images to remove."; \
else \
echo "Aborting."; \
fi
# ---------------------------------
# For deploying modules to AWS
# ---------------------------------
deploy:
$(MAKE) -C terraform/modules deploy-all
deploy-%:
$(call run_deploy_or_destroy,deploy,$*)
destroy:
$(MAKE) -C terraform/modules destroy-all
destroy-%:
$(call run_deploy_or_destroy,destroy,$*)
plan:
$(MAKE) -C terraform/modules plan-all
plan-%:
$(call run_deploy_or_destroy,plan,$*)
# ---------------------------------
# For deploying shared/backend to AWS
# This should only be run once
# Please do not run the below commands because they are initialised in AWS already
# ---------------------------------
deploy-shared:
$(MAKE) -C terraform/shared deploy-shared
destroy-shared:
$(MAKE) -C terraform/shared destroy-shared
plan-shared:
$(MAKE) -C terraform/shared plan-shared