-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_aws.sh
107 lines (93 loc) · 2.33 KB
/
run_aws.sh
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
#!/bin/sh
# run_aws.sh
# 2023-02-02 | CR
#
APP_DIR='chalicelib'
PYTHON3_EXEC='/usr/local/bin/python3.9'
AWS_STACK_NAME='mediabros-apis-stack'
ENV_FILESPEC=""
if [ -f "./.env" ]; then
ENV_FILESPEC="./.env"
fi
if [ -f "../.env" ]; then
ENV_FILESPEC="../.env"
fi
if [ "$ENV_FILESPEC" != "" ]; then
set -o allexport; source ${ENV_FILESPEC}; set +o allexport ;
fi
if [ "$PORT" = "" ]; then
PORT="5001"
fi
if [ "$1" = "pipfile" ]; then
deactivate ;
# https://realpython.com/intro-to-pyenv/
pipenv --python 3.9
pipenv install requests
pipenv install openai
pipenv install "python-jose[cryptography]"
pipenv install "passlib[bcrypt]"
pipenv install wheel
pipenv install python-multipart
pipenv install python-dotenv
# FasAPI
pipenv install fastapi
# pipenv install a2wsgi
# Mongo
pipenv install pymongo
pipenv install werkzeug
# AWS
pipenv install boto3
pipenv install chalice
pipenv lock
pipenv requirements > requirements.txt
fi
if [ "$1" = "clean" ]; then
echo "Cleaning..."
cd ${APP_DIR} ;
deactivate ;
rm -rf __pycache__ ;
rm -rf ../__pycache__ ;
rm -rf bin ;
rm -rf include ;
rm -rf lib ;
rm -rf src ;
rm -rf pyvenv.cfg ;
rm -rf .vercel/cache ;
rm -rf ../.vercel/cache ;
rm -rf ../node_modules ;
rm requirements.txt
ls -lah
fi
if [[ "$1" = "test" ]]; then
# echo "Error: no test specified" && exit 1
echo "Run test..."
python -m pytest
echo "Done..."
fi
if [[ "$1" = "run" || "$1" = "" ]]; then
pipenv run chalice local --port ${PORT}
exit
fi
if [ "$1" = "deploy" ]; then
pipenv requirements > requirements.txt
pipenv run chalice deploy --stage dev
exit
fi
if [ "$1" = "deploy_prod" ]; then
pipenv requirements > requirements.txt
pipenv run chalice deploy --stage prod
exit
fi
if [ "$1" = "create_stack" ]; then
aws cloudformation deploy --template-file "${APP_DIR}/.chalice/dynamodb_cf_template.yaml" --stack-name "${AWS_STACK_NAME}"
# aws cloudformation describe-stack-events --stack-name "${AWS_STACK_NAME}"
fi
if [ "$1" = "delete_app" ]; then
# Delete application
pipenv run chalice delete
exit
fi
if [ "$1" = "delete_stack" ]; then
# Delete DynamoDb table
aws cloudformation delete-stack --stack-name "${AWS_STACK_NAME}"
fi