- Split differrent caching mechanisms (types, version tree, config) into different cachers - Improve resource usage on starting components, and correct gevent usage - Refine repopack usage for eveai_app (too large) - Change nginx dockerfile to allow for specialist overviews being served statically
53 lines
2.1 KiB
Bash
Executable File
53 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
cd "/app" || exit 1
|
|
export PYTHONPATH="$PYTHONPATH:/app/"
|
|
|
|
# Ensure we can write the logs
|
|
chown -R appuser:appuser /app/logs
|
|
|
|
# Wait for the database to be ready
|
|
echo "Waiting for database to be ready"
|
|
until pg_isready -h $DB_HOST -p $DB_PORT; do
|
|
echo "Postgres is unavailable - sleeping"
|
|
sleep 2
|
|
done
|
|
echo "Postgres is up - executing commands"
|
|
|
|
export PGPASSWORD=$DB_PASS
|
|
# Check if the database exists and initialize if not
|
|
if ! psql -U $DB_USER -h $DB_HOST -p $DB_PORT -d $DB_NAME -c '\dt' | grep -q 'No relations found'; then
|
|
echo "Database eveai does not exist or is empty. Initializing..."
|
|
psql -U $DB_USER -h $DB_HOST -p $DB_PORT -d postgres -c "CREATE DATABASE $DB_NAME;"
|
|
psql -U $DB_USER -h $DB_HOST -p $DB_PORT -d $DB_NAME -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
|
fi
|
|
|
|
echo "Applying migrations to the public and tenant schema..."
|
|
|
|
# Set FLASK_APP environment variables
|
|
PROJECT_DIR="/app"
|
|
export FLASK_APP=${PROJECT_DIR}/scripts/run_eveai_app.py # Adjust the path to your Flask app entry point
|
|
export PYTHONPATH="$PROJECT_DIR/patched_packages:$PYTHONPATH:$PROJECT_DIR" # Include the app directory in the Python path & patched packages
|
|
|
|
# Run Alembic upgrade for the public schema
|
|
echo "Applying migrations to the public schema..."
|
|
flask db upgrade -d "${PROJECT_DIR}/migrations/public"
|
|
echo "Finished applying migrations to the public schema..."
|
|
|
|
# Run Alembic upgrade for the tenant schema
|
|
echo "Applying migrations to the tenant schema..."
|
|
flask db upgrade -d "${PROJECT_DIR}/migrations/tenant"
|
|
echo "Finished applying migrations to the tenant schema..."
|
|
|
|
# Set flask environment variables
|
|
#export FLASK_ENV=development # Use 'production' as appropriate
|
|
#export FLASK_DEBUG=1 # Use 0 for production
|
|
|
|
# Initialize initial data (tenant and user)
|
|
echo "Initializing initial tenant and user..."
|
|
python ${PROJECT_DIR}/scripts/initialize_data.py # Adjust the path to your initialization script
|
|
|
|
# Start Flask app
|
|
# gunicorn -w 1 -k gevent -b 0.0.0.0:5001 --worker-connections 100 scripts.run_eveai_app:app
|
|
gunicorn -w 1 -k gevent -b 0.0.0.0:5001 --worker-connections 100 scripts.run_eveai_app:app
|