-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·107 lines (90 loc) · 3.84 KB
/
run.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/bash
# AWSプロファイルの読み込み
source .env
if [ $# = 0 ]; then
echo "doc(ker) -> docker系の実行"
echo " .ex: ./run.sh doc exec app bash"
echo " fl(ake8) flake8の実行"
echo " b(ash) bashの実行"
echo " i(nstall) 依存関係のzipファイル作成"
echo " fa(stapi) fastApiの実行"
echo " op(enapi) openAPIの再生成"
echo " (py)te(st) pytestの実行"
echo "in(voke) -> ローカルでの実行"
echo " i(nstall) 依存関係のzip作成もセット"
echo "mi(grate) -> マイグレーションの実行, (引数ありでその環境に対して)"
echo "de?p(loy) -> デプロイ"
exit 1
elif [[ $1 =~ pre(-commit)? ]]; then
docker-compose -f api/docker/docker-compose.yaml exec app poetry run pflake8
elif [[ $1 =~ doc(ker)? ]]; then
if [[ $2 =~ fl(ake8)? ]]; then
echo docker-compose exec app poetry run pflake8 src/
docker-compose -f api/docker/docker-compose.yaml exec app poetry run pflake8 src/
exit 1
elif [[ $2 =~ b(ash)? ]]; then
echo docker-compose exec app bash
docker-compose -f api/docker/docker-compose.yaml exec app bash
exit 1
elif [[ $2 =~ in(stall)? ]]; then
echo docker-compose run app ./run.sh install
docker-compose -f api/docker/docker-compose.yaml run --rm app ./run.sh install
exit 1
elif [[ $2 =~ fa(stapi)? ]]; then
echo docker-compose exec app ./run.sh fastapi
docker-compose -f api/docker/docker-compose.yaml exec app ./run.sh fastapi
exit 1
elif [[ $2 =~ op(enapi)? ]]; then
echo docker-compose exec app poetry run fastapi_to_openapi -i src/main
docker-compose -f api/docker/docker-compose.yaml exec app poetry run fastapi_to_openapi -i src/main
mv api/openapi.yaml rest_client/openapi.yaml
exit 1
elif [[ $2 =~ (py)?te(st)? ]]; then
shift;shift;
echo docker-compose exec app poetry run pytest $@
docker-compose -f api/docker/docker-compose.yaml exec app poetry run pytest $@
exit 1
fi
shift
echo docker-compose -f api/docker/docker-compose.yaml $@
docker-compose -f api/docker/docker-compose.yaml $@
elif [ $1 = "db" ]; then
echo -e "- local : local_db\n- local_test : local_test_db\n"
if command -v mysql &> /dev/null; then
echo 'mysql -u root -h 127.0.0.1 --port 33306 -t local_db -p'
mysql -u root -h 127.0.0.1 --port 33306 -t local_db -p
else
echo "docker-compose exec db bash"
echo " -> mysql -u root -p"
docker-compose -f api/docker/docker-compose.yaml exec db mysql -u root -t local_db -p
fi
elif [[ $1 =~ in(voke)? ]]; then
if [[ $2 =~ i(nstall)? ]]; then
echo docker-compose -f api/docker/docker-compose.yaml run app ./run.sh install
docker-compose -f api/docker/docker-compose.yaml run app ./run.sh install
fi
echo npm run cdk -c environment=local synth
npm run cdk:local synth
echo sam local start-api
sam local start-api -t ./cdk.out/LambdaFastapiStack-dev.template.json --docker-network lambda_fastapi_backend
elif [[ $1 =~ mi(grate)? ]]; then
if [ $# -eq 2 ]; then
echo npm run env -- -e $2
npm run env -- -e $2
fi
echo docker-compose doc exec app ./run.sh alembic migrate
docker-compose -f api/docker/docker-compose.yaml up app -d
docker-compose -f api/docker/docker-compose.yaml exec app ./run.sh alembic migrate
npm run env
docker-compose -f api/docker/docker-compose.yaml up app -d
exit 1
elif [[ $1 =~ de?p(loy)? ]]; then
if [ "$2" = "prod" ]; then
echo npm run cdk:prod deploy -- --profile $PROFILE
npm run cdk:prod deploy -- --profile $PROFILE
exit 1
fi
echo npm run cdk:dev deploy -- --profile $PROFILE
npm run cdk:dev deploy -- --profile $PROFILE
exit 1
fi