Files
digiserver/entrypoint.sh
ske087 756f9052b5 Fix Docker deployment issues and add fresh database support
- Fix: Add missing 'click' import to app.py to resolve startup error
- Fix: Update docker-compose.yml volume mappings to use correct persistent storage paths (/opt/digi-s)
- Improve: Enhanced entrypoint.sh for better database initialization
- Update: Configuration files for improved deployment

This resolves the Docker container startup issues and ensures proper persistent storage.
2025-07-18 15:40:57 -04:00

35 lines
987 B
Bash
Executable File

#!/bin/bash
set -e
# Create necessary directories
mkdir -p static/uploads static/resurse
mkdir -p instance
# Check if database exists
if [ ! -f instance/dashboard.db ]; then
echo "No database found, initializing..."
# Remove and recreate migrations directory to ensure clean state
rm -rf migrations
mkdir -p migrations
# Initialize the database
flask db init
flask db migrate -m "Initial migration"
flask db upgrade
# Create admin user if environment variables are set
if [ -n "$ADMIN_USER" ] && [ -n "$ADMIN_PASSWORD" ]; then
echo "Creating admin user: $ADMIN_USER"
flask create-admin --username "$ADMIN_USER" --password "$ADMIN_PASSWORD"
else
echo "Warning: ADMIN_USER or ADMIN_PASSWORD not set, skipping admin creation"
fi
else
echo "Existing database found, applying migrations..."
flask db upgrade
fi
echo "Starting DigiServer..."
# Start the application
exec flask run --host=0.0.0.0