#!/usr/bin/env sh
set -e

# Make database writable
chown -R guest "$DB_DIR"

if [ "$1" = 'dev' ]; then
  export DJANGO_ENV='development'
  exec python3 manage.py runserver 0.0.0.0:8000
elif [ "$1" = 'prod' ]; then
  export DJANGO_ENV='production'
  # Collect static files
  python3 manage.py collectstatic --noinput --clear -v 0
  # translations generation
  python3 manage.py compilemessages
  exec uwsgi --ini uwsgi.ini --pythonpath "$APPS_DIR" --static-map=/static/="$STATIC_ROOT"
fi

exec "$@"
