Files
web2.0-backend/production_entrypoint.sh
T
2020-07-16 01:35:11 +03:00

33 lines
857 B
Bash
Executable File

#!/bin/sh
# Get ENVs from secrets
if test -f "$SECRET_KEY_FILE"; then
export SECRET_KEY=$(cat $SECRET_KEY_FILE)
fi
if test -f "$TG_BOT_TOKEN_FILE"; then
export TG_BOT_TOKEN=$(cat $TG_BOT_TOKEN_FILE)
fi
if test -f "$EMAIL_API_KEY_FILE"; then
export EMAIL_API_KEY=$(cat $EMAIL_API_KEY_FILE)
fi
if test -f "$EMAIL_API_SECRET_FILE"; then
export EMAIL_API_SECRET=$(cat $EMAIL_API_SECRET_FILE)
fi
if test -f "$DB_USER_FILE"; then
export DB_USER=$(cat $DB_USER_FILE)
fi
if test -f "$DB_PASSWD_FILE"; then
export DB_PASSWD=$(cat $DB_PASSWD_FILE)
fi
# Collect static files
echo "Collect static files"
python manage.py collectstatic --noinput
# Apply database migrations
echo "Apply database migrations"
python manage.py migrate
# Start server
echo "Django running on http://localhost:8000 in production mode"
gunicorn -w 4 -b 0.0.0.0:8000 sikweb.wsgi