-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.sh
70 lines (44 loc) · 1.43 KB
/
scripts.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
#!/bin/bash
action=$1
prestart() {
printf "\n-- init prestart -----------------------\n"
# Execute migrations
alembic upgrade head
# Create default scopes
python manage.py core create-default-scopes
# Create super user
python manage.py core create-superuser
# Insert initial data
python manage.py universities insert-initial-data
printf "\n-- finish prestart -----------------------\n"
}
build_img() {
version=$1
[ -z "$version" ] && version=0.1 && echo "\nset defaul version 0.1\n"
docker build --no-cache -t crissalvarezh/ubicor-api:$version .
docker tag crissalvarezh/ubicor-api:$version crissalvarezh/ubicor-api:latest
}
push_img() {
version=$1
docker push crissalvarezh/ubicor-api:$version
docker push crissalvarezh/ubicor-api:latest
}
if [ "$action" = "start" ]; then
prestart
uvicorn app.main:app --proxy-headers --host 0.0.0.0 --port 80
elif [ "$action" = "dev" ]; then
uvicorn app.main:app --reload
elif [ "$action" = "prestart" ]; then
prestart
elif [ "$action" = "build" ]; then
build_img "$2"
elif [ "$action" = "publish" ]; then
build_img "$2"
push_img "$2"
elif [ "$action" = "push-img" ]; then
push_img "$2"
elif [ "$action" = "deploy" ]; then
ssh -o StrictHostKeyChecking=no \
-i ./server-key.pem [email protected] \
"cd /home/ec2-user/cristian-projects-server && make reload service=ubicor-api"
fi