generated from MinBZK/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·51 lines (43 loc) · 1 KB
/
docker-entrypoint.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
#!/usr/bin/env bash
DATABASE_MIGRATE=""
HOST="0.0.0.0"
LOGLEVEL="warning"
PORT="8000"
while getopts "dh:l:p:" opt; do
case $opt in
d)
DATABASE_MIGRATE="True"
;;
h)
HOST=$OPTARG
;;
l)
LOGLEVEL=$OPTARG
;;
p)
PORT=$OPTARG
;;
:)
echo "Option -${OPTARG} requires an argument."
exit 1
;;
?)
echo "Invalid option: $OPTARG"
echo "Usage: docker-entrypoint.sh [-d] [-h host] [-l loglevel]"
exit 1
;;
esac
done
echo "DATABASE_MIGRATE: $DATABASE_MIGRATE"
echo "HOST: $HOST"
echo "LOGLEVEL: $LOGLEVEL"
echo "PORT: $PORT"
if [ -z $DATABASE_MIGRATE ]; then
echo "Upgrading database"
if ! alembic upgrade head; then
echo "Failed to upgrade database"
exit 1
fi
fi
echo "Starting server"
python -m uvicorn --host "$HOST" amt.server:app --port "$PORT" --log-level "$LOGLEVEL"