Docker deployment Realised
This commit is contained in:
@@ -1,15 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/bash
|
||||
|
||||
cd "/Volumes/OWC4M2_1/Dropbox/Josako's Dev/Josako/EveAI/Development/eveAI/" || exit 1
|
||||
source "/Volumes/OWC4M2_1/Dropbox/Josako's Dev/Josako/EveAI/Development/eveAI/.venv/bin/activate"
|
||||
cd "/app" || exit 1
|
||||
export PYTHONPATH="$PYTHONPATH:/app/"
|
||||
|
||||
export PYTHONPATH="$PYTHONPATH:/Volumes/OWC4M2_1/Dropbox/Josako's Dev/Josako/EveAI/Development/eveAI/"
|
||||
# Wait for the database to be ready
|
||||
echo "Waiting for database to be ready"
|
||||
until pg_isready -h db -p 5432; do
|
||||
echo "Postgres is unavailable - sleeping"
|
||||
sleep 2
|
||||
done
|
||||
echo "Postgres is up - executing commands"
|
||||
|
||||
export PGPASSWORD=Skywalker!
|
||||
# Check if the database exists and initialize if not
|
||||
if ! psql -U luke -h db -d eveai -c '\dt' | grep -q 'No relations found'; then
|
||||
echo "Database eveai does not exist or is empty. Initializing..."
|
||||
psql -U luke -h db -d postgres -c "CREATE DATABASE eveai;"
|
||||
psql -U luke -h db -d eveai -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="$PYTHONPATH:$PROJECT_DIR" # Include the app directory in the Python path
|
||||
|
||||
# Run Alembic upgrade for the public schema
|
||||
echo "Applying migrations to the public schema..."
|
||||
flask db upgrade -d "${PROJECT_DIR}/migrations/public"
|
||||
|
||||
# Run Alembic upgrade for the tenant schema
|
||||
echo "Applying migrations to the tenant schema..."
|
||||
flask db upgrade -d "${PROJECT_DIR}/migrations/tenant"
|
||||
|
||||
# Set flask environment variables
|
||||
export FLASK_ENV=development # Use 'production' as appropriate
|
||||
export FLASK_DEBUG=1 # Use 0 for production
|
||||
#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 4 -k gevent -b 0.0.0.0:5001 scripts.run_eveai_app:app
|
||||
|
||||
deactivate
|
||||
Reference in New Issue
Block a user