-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.sh
executable file
·28 lines (23 loc) · 953 Bytes
/
startup.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
#!/bin/sh
apply_migrations() {
echo "Applying database migrations..."
if ! alembic upgrade head; then
echo "Error applying migrations"
exit 1
fi
}
if [ "$ENV" = "dev" ]; then
echo "Starting FastAPI in development mode with SSL..."
SSL_KEYFILE="./certs/key.pem"
SSL_CERTFILE="./certs/cert.pem"
uvicorn app.main:app --host 0.0.0.0 --port 443 --ssl-keyfile=$SSL_KEYFILE --ssl-certfile=$SSL_CERTFILE --log-config ./logging.conf
else
# Export all environment variables safely for Azure
eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile)
# Set the default environment to production if not specified
ENV=${ENV:-production}
# Apply database migrations
apply_migrations
echo "Starting FastAPI in production mode..."
uvicorn app.main:app --host 0.0.0.0 --port 8000 --log-config ./logging.conf
fi