@@ -5,50 +5,67 @@ ENV=dev
5
5
SHELL := /bin/bash
6
6
7
7
help :
8
- echo " make build | build the SAM project"
9
- echo " make serve | alias for serve-https"
10
- echo " make clean | remove all installed dependencies and build artifacts"
11
- echo " make deps | install all dependencies"
12
- echo " make link | create hard links to allow for hot reloading of a built project"
13
- echo " make secrets | symlink secrets files from ../tfvars"
14
- echo " make start-with-step | run the SAM server locally with step function & download lambdas"
15
- echo " make style | run all style checks"
16
- echo " make test | run all tests"
17
- echo " make cover | run all tests with coverage"
18
- echo " make env ENV=[env] | activate env.\$ $ENV .json file (default: dev)"
19
- echo " make deps-node | install node dependencies"
20
- echo " make deps-python | install python dependencies"
21
- echo " make serve-http | run the SAM server locally (HTTP on port 3000)"
22
- echo " make serve-https | run the SAM server locally (HTTPS on port 3002)"
23
- echo " make style-node | run node code style check"
24
- echo " make style-python | run python code style check"
25
- echo " make test-node | run node tests"
26
- echo " make test-python | run python tests"
27
- echo " make cover-node | run node tests with coverage"
28
- echo " make cover-python | run python tests with coverage"
29
- .aws-sam/build.toml : ./template.yaml node/package-lock.json node/src/package-lock.json chat/dependencies/requirements.txt chat/src/requirements.txt
30
- sed -Ei.orig ' s/^(\s+)#\*\s/\1/' template.yaml
31
- sed -Ei.orig ' s/^(\s+)#\*\s/\1/' chat/template.yaml
32
- sam build --cached --parallel
33
- mv template.yaml.orig template.yaml
34
- mv chat/template.yaml.orig chat/template.yaml
35
- deps-node :
36
- cd node/src ; \
8
+ echo " make build | build the SAM project"
9
+ echo " make serve | alias for serve-https"
10
+ echo " make clean | remove all installed dependencies and build artifacts"
11
+ echo " make deps | install all dependencies"
12
+ echo " make env.json | create an env.json file for the current user's environment"
13
+ echo " make link | create hard links to allow for hot reloading of a built project"
14
+ echo " make secrets | symlink secrets files from ../tfvars"
15
+ echo " make start-with-step | run the SAM server locally with step function & download lambdas"
16
+ echo " make style | run all style checks"
17
+ echo " make test | run all tests"
18
+ echo " make cover | run all tests with coverage"
19
+ echo " make env ENV=[env] | activate env.\$ $ENV .json file (default: dev)"
20
+ echo " make deps-node | install node dependencies"
21
+ echo " make deps-python | install python dependencies"
22
+ echo " make samconfig.NAME.yaml" | create a user samconfig file for the specified username"
23
+ echo " make build | build the SAM project for deploying"
24
+ echo " make deploy | deploy the SAM project to AWS"
25
+ echo " make sync | sync the SAM project to AWS for quick development"
26
+ echo " make sync-code | sync the SAM project to AWS (code changes only)"
27
+ echo " make serve-http | run the SAM server locally (HTTP on port 3000)"
28
+ echo " make serve-https | run the SAM server locally (HTTPS on port 3002)"
29
+ echo " make style-node | run node code style check"
30
+ echo " make style-python | run python code style check"
31
+ echo " make test-node | run node tests"
32
+ echo " make test-python | run python tests"
33
+ echo " make cover-node | run node tests with coverage"
34
+ echo " make cover-python | run python tests with coverage"
35
+
36
+ .aws-sam/build.toml : ./template.yaml api/package-lock.json api/src/package-lock.json chat/dependencies/requirements.txt chat/src/requirements.txt
37
+ sed -Ei.orig ' s/"dependencies"/"devDependencies"/' api/src/package.json
38
+ cp api/src/package-lock.json api/src/package-lock.json.orig
39
+ cd api/src && npm i --package-lock-only && cd -
40
+ for d in . api av-download chat docs ; do \
41
+ sed -Ei.orig ' s/^(\s+)#\*\s/\1/' $$ d/template.yaml; \
42
+ done
43
+
44
+ -sam build --cached --parallel
45
+
46
+ for d in . api av-download chat docs ; do \
47
+ mv $$d/template.yaml.orig $$d/template.yaml; \
48
+ done
49
+ mv api/src/package.json.orig api/src/package.json
50
+ mv api/src/package-lock.json.orig api/src/package-lock.json
51
+ deps-api :
52
+ cd api/src ; \
37
53
npm list > /dev/null 2>&1 ; \
38
54
src_deps=$$? ; \
39
55
cd .. ; \
40
56
npm list > /dev/null 2>&1 ; \
41
57
dev_deps=$$? ; \
42
58
test $$ src_deps -eq 0 -a $$ dev_deps -eq 0 || npm ci
43
-
44
- cd lambdas ;\
59
+ deps-av-download :
60
+ cd av-download/ lambdas ; \
45
61
npm list > /dev/null 2>&1 || npm ci
62
+ deps-node : deps-api deps-av-download
46
63
cover-node : deps-node
47
- cd node && npm run test:coverage
64
+ cd api && npm run test:coverage
48
65
style-node : deps-node
49
- cd node && npm run prettier
66
+ cd api && npm run prettier
50
67
test-node : deps-node
51
- cd node && npm run test
68
+ cd api && npm run test
52
69
deps-python :
53
70
cd chat/src && pip install -r requirements.txt && pip install -r requirements-dev.txt
54
71
cover-python : deps-python
@@ -63,30 +80,51 @@ test-python: deps-python
63
80
cd chat && pytest
64
81
python-version :
65
82
cd chat && python --version
66
- build : .aws-sam/build.toml
67
- serve-http : deps-node
83
+ build :
84
+ bash -c " trap 'trap - SIGINT SIGTERM ERR; $( MAKE) reset; exit 1' SIGINT SIGTERM ERR; $( MAKE) .aws-sam/build.toml reset"
85
+ validate :
86
+ cfn-lint template.yaml ** /template.yaml --ignore-checks E3510 W1028 W8001
87
+ serve-http : deps-node env.json
68
88
@printf ' \033[0;31mWARNING: Serving only the local HTTP API. The chat websocket API is not available in local mode.\033[0m\n'
69
89
rm -rf .aws-sam
70
- sam local start-api --host 0.0.0.0 --log-file dc-api.log ${SERVE_PARAMS}
90
+ sam local start-api -t api/template.yaml --env-vars $$ PWD/env.json - -host 0.0.0.0 --log-file dc-api.log ${SERVE_PARAMS}
71
91
serve-https : SERVE_PARAMS = --port 3002 --ssl-cert-file $$HOME/.dev_cert/dev.rdc.cert.pem --ssl-key-file $$HOME/.dev_cert/dev.rdc.key.pem
72
92
serve-https : serve-http
73
93
serve : serve-https
74
- start-with-step : deps-node
75
- sam local start-lambda -- host 0.0.0.0 --port 3005 --env-vars env.json --log-file lambda.log & \
94
+ start-with-step : deps-node env.json
95
+ sam local start-lambda -t av-download/template.yaml -- host 0.0.0.0 --port 3005 --env-vars $$ PWD/ env.json --log-file lambda.log & \
76
96
echo $$ ! > .sam-pids ; \
77
- sam local start-api --host 0.0.0.0 --port 3002 --log-file dc-api.log \
97
+ sg open all 3005 ; \
98
+ sam local start-api -t api/template.yaml --env-vars $$ PWD/env.json --host 0.0.0.0 --port 3002 --log-file dc-api.log \
78
99
--ssl-cert-file $$ HOME/.dev_cert/dev.rdc.cert.pem --ssl-key-file $$ HOME/.dev_cert/dev.rdc.key.pem & \
79
100
echo $$ ! >> .sam-pids ; \
80
101
docker run --rm -p 8083:8083 -e LAMBDA_ENDPOINT=http://172.17.0.1:3005/ amazon/aws-stepfunctions-local ; \
102
+ echo -n " Shutting down..." ; \
103
+ sg close all 3005 ; \
81
104
kill $$(cat .sam-pids ) ; \
82
- rm -f .sam-pids
105
+ rm -f .sam-pids ; \
106
+ echo " "
107
+ state-machine :
108
+ export TEMPLATE_DIR=$$(mktemp -d ) ; \
109
+ yq -o=json ' .Resources.avDownloadStateMachine.Properties.Definition' av-download/template.yaml > $$ TEMPLATE_DIR/av_download.json; \
110
+ aws stepfunctions create-state-machine --endpoint http://localhost:8083 --definition file://$$ TEMPLATE_DIR/av_download.json --name " hlsStitcherStepFunction" --role-arn arn:aws:iam::012345678901:role/DummyRole
83
111
deps : deps-node deps-python
84
112
style : style-node style-python
85
113
test : test-node test-python
86
114
cover : cover-node cover-python
87
- env :
88
- ln -fs ./env.${ENV} .json ./env.json
115
+ env.json :
116
+ ./bin/make_env.sh
117
+ samconfig.% .yaml :
118
+ DEV_PREFIX=$* ./bin/make_deploy_config.sh
119
+ deploy : build samconfig.$(DEV_PREFIX ) .yaml
120
+ sam deploy --config-file samconfig.$(DEV_PREFIX ) .yaml --stack-name dc-api-$(DEV_PREFIX )
121
+ sync : samconfig.$(DEV_PREFIX ) .yaml
122
+ sam sync --config-file samconfig.$(DEV_PREFIX ) .yaml --stack-name dc-api-$(DEV_PREFIX ) --watch $(ARGS )
123
+ sync-code : ARGS=--code
124
+ sync-code : sync
89
125
secrets :
90
- ln -s ../tfvars/dc-api/* .
126
+ ln -s ../tfvars/dc-api/* .yaml .
91
127
clean :
92
- rm -rf .aws-sam node/node_modules node/src/node_modules python/** /__pycache__ python/.coverage python/.ruff_cache
128
+ rm -rf .aws-sam api/.aws-sam chat/.aws-sam av-download/.aws-sam api/node_modules api/src/node_modules chat/** /__pycache__ chat/.coverage chat/.ruff_cache
129
+ reset :
130
+ for f in $$ (find . -maxdepth 2 -name ' *.orig' ); do mv $$ f $$ {f%%.orig}; done
0 commit comments