#!/bin/bash

ENVIRONMENT="${ENVIRONMENT:-dev}"
ADMIN_USER="${ADMIN_USER:-admin}"
ADMIN_PASSWORD="${ADMIN_PASSWORD:-789789}"

# INIT
echo "[INIT] Initializing the database"
flask db upgrade
echo "[INIT] Initializing data for env: $ENVIRONMENT"
flask data init ${ENVIRONMENT}
echo "[INIT] Initializing admin user: ${ADMIN_USER}"
flask users create ${ADMIN_USER} --password ${ADMIN_PASSWORD}

# RUN THE SERVER
gunicorn -b 0.0.0.0:8000 --access-logfile - --reload "app:app"

