-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
149 lines (114 loc) · 6.65 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
## ----------------------------------------------------------------------------
## The purpose of this Makefile is to help document some of the commonly run
## tasks for DeepRacer Event Manager (DREM).
## ----------------------------------------------------------------------------
## CONFIG
include build.config
ifndef label
override label = main
endif
ifndef source_repo
override source_repo = aws-solutions-library-samples/guidance-for-aws-deepracer-event-management
endif
ifndef source_branch
override source_branch = release/stable
endif
## CONSTANTS
dremSrcPath := website/src
leaderboardSrcPath := website-leaderboard/src
overlaysSrcPath := website-stream-overlays/src
## ----------------------------------------------------------------------------
.PHONY: help
help: ## Show this help.
@sed -ne '/@sed/!s/## //p' $(MAKEFILE_LIST)
.PHONY: install
install: pipeline.deploy ## Uploads the artifact and build the deploy pipeline
.PHONY: bootstrap
bootstrap: ## Bootstraps the CDK environment
cdk bootstrap -c email=$(email) -c label=$(label) -c account=$(account_id) -c region=$(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo)
.PHONY: clean
clean: pipeline.clean s3.clean
## Dev related targets
pipeline.synth: ## Synth the CDK pipeline
npx cdk synth -c email=$(email) -c label=$(label) -c account=$(account_id) -c region=$(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo)
pipeline.deploy: ## Deploy the CDK pipeline
npx cdk deploy -c email=$(email) -c label=$(label) -c account=$(account_id) -c region=$(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo)
pipeline.clean: ## Destroys the CDK pipeline
npx cdk destroy -c email=$(email) -c label=$(label) -c account=$(account_id) -c region=$(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo)
drem.clean-infrastructure: ## Delete DREM application
aws cloudformation delete-stack --stack-name drem-backend-$(label)-infrastructure --region $(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo)
drem.clean-base: ## Delete DREM application
aws cloudformation delete-stack --stack-name drem-backend-$(label)-base --region $(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo)
manual.deploy: ## Deploy via cdk
npx cdk deploy --c manual_deploy=True -c email=$(email) -c label=$(label) -c account=$(account_id) -c region=$(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo) --all
manual.deploy.hotswap: ## Deploy via cdk --hotswap
npx cdk deploy --c manual_deploy=True -c email=$(email) -c label=$(label) -c account=$(account_id) -c region=$(region) -c source_branch=$(source_branch) -c source_repo=$(source_repo) --all --hotswap
local.install: ## Install Javascript dependencies
npm install
local.config: ## Setup local config based on branch
echo "{}" > ${dremSrcPath}/config.json
aws cloudformation describe-stacks --region $(region) --stack-name drem-backend-$(label)-infrastructure --query 'Stacks[0].Outputs' > cfn.outputs
python3 scripts/generate_amplify_config_cfn.py
appsyncId=`cat appsyncId.txt` && aws appsync get-introspection-schema --region $(region) --api-id $$appsyncId --format SDL ./$(dremSrcPath)/graphql/schema.graphql
current_dir=$(pwd)
cd $(dremSrcPath)/graphql/ && amplify codegen
cd $(current_dir)
echo "{}" > $(leaderboardSrcPath)/config.json
python3 scripts/generate_leaderboard_amplify_config_cfn.py
appsyncId=`cat appsyncId.txt` && aws appsync get-introspection-schema --region $(region) --api-id $$appsyncId --format SDL $(leaderboardSrcPath)/graphql/schema.graphql
cd $(leaderboardSrcPath)/graphql/ && amplify codegen
cd $(current_dir)
echo "{}" > $(overlaysSrcPath)/config.json
python3 scripts/generate_stream_overlays_amplify_config_cfn.py
appsyncId=`cat appsyncId.txt` && aws appsync get-introspection-schema --region $(region) --api-id $$appsyncId --format SDL $(overlaysSrcPath)/graphql/schema.graphql
cd $(overlaysSrcPath)/graphql/ && amplify codegen
cd $(current_dir)
local.config.docker: ## Setup local config based on branch
echo "{}" > ${dremSrcPath}/config.json
aws cloudformation describe-stacks --region $(region) --stack-name drem-backend-$(label)-infrastructure --query 'Stacks[0].Outputs' > cfn.outputs
python3 scripts/generate_amplify_config_cfn.py --docker
appsyncId=`cat appsyncId.txt` && aws appsync get-introspection-schema --region $(region) --api-id $$appsyncId --format SDL ./$(dremSrcPath)/graphql/schema.graphql
current_dir=$(pwd)
cd $(dremSrcPath)/graphql/ && amplify codegen
cd $(current_dir)
echo "{}" > $(leaderboardSrcPath)/config.json
python3 scripts/generate_leaderboard_amplify_config_cfn.py
appsyncId=`cat appsyncId.txt` && aws appsync get-introspection-schema --region $(region) --api-id $$appsyncId --format SDL $(leaderboardSrcPath)/graphql/schema.graphql
cd $(leaderboardSrcPath)/graphql/ && amplify codegen
cd $(current_dir)
echo "{}" > $(overlaysSrcPath)/config.json
python3 scripts/generate_stream_overlays_amplify_config_cfn.py
appsyncId=`cat appsyncId.txt` && aws appsync get-introspection-schema --region $(region) --api-id $$appsyncId --format SDL $(overlaysSrcPath)/graphql/schema.graphql
cd $(overlaysSrcPath)/graphql/ && amplify codegen
cd $(current_dir)
local.run: ## Run the frontend application locally for development
PORT=3000 npm start --prefix website
local.clean: ## Remove local packages and modules
-rm package-lock.json
rm -rf node_modules
-rm website/package-lock.json
rm -rf website/node_modules
-rm website-leaderboard/package-lock.json
rm -rf website-leaderboard/node_modules
-rm website-stream-overlays/package-lock.json
rm -rf website-stream-overlays/node_modules
local.run-leaderboard: ## Run the frontend leaderboard application locally for development
PORT=3001 npm start --prefix website-leaderboard
local.run-overlays: ## Run the frontend overlays application locally for development
PORT=3002 npm start --prefix website-stream-overlays
local.docker.build: ## Build DREM docker services
docker compose build --no-cache website leaderboard overlays
local.docker.up: ## Run DREM using docker for development
docker compose up -d
local.docker.logs: ## View the DREM docker logs
docker compose logs -f
local.docker.down: ## Stop DREM docker instance
docker compose down
local.docker.clean: ## Remove DREM docker container and volumes (destructive)
docker compose rm website -f -v
docker compose rm leaderboard -f -v
docker compose rm overlays -f -v
leaderboard.zip:
-rm website/public/leaderboard-timer.zip
zip -r website/public/leaderboard-timer.zip leaderboard-timer -x "*.git*" -x "*node_modules*" -x "*stl*" -x "*.DS_Store"
.NOTPARALLEL: