Initial commit: Quality App v2 - FG Scan Module with Reports
This commit is contained in:
72
docker-entrypoint.sh
Executable file
72
docker-entrypoint.sh
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
# Docker entrypoint script for Quality App v2
|
||||
|
||||
set -e
|
||||
|
||||
echo "Starting Quality App v2 initialization..."
|
||||
|
||||
# Wait for MariaDB to be ready using Python
|
||||
if [ ! -z "$DB_HOST" ]; then
|
||||
echo "Waiting for MariaDB at $DB_HOST:$DB_PORT..."
|
||||
python3 << 'EOF'
|
||||
import socket
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
|
||||
host = os.getenv('DB_HOST', 'localhost')
|
||||
port = int(os.getenv('DB_PORT', '3306'))
|
||||
max_attempts = 30
|
||||
attempt = 0
|
||||
|
||||
while attempt < max_attempts:
|
||||
try:
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock.settimeout(5)
|
||||
result = sock.connect_ex((host, port))
|
||||
sock.close()
|
||||
if result == 0:
|
||||
print(f"MariaDB is ready at {host}:{port}")
|
||||
break
|
||||
except Exception as e:
|
||||
pass
|
||||
attempt += 1
|
||||
print(f"Attempt {attempt}/{max_attempts}: MariaDB not ready yet, waiting...")
|
||||
time.sleep(2)
|
||||
|
||||
if attempt == max_attempts:
|
||||
print("MariaDB did not become ready in time")
|
||||
sys.exit(1)
|
||||
EOF
|
||||
|
||||
# Initialize database
|
||||
echo "Initializing database..."
|
||||
python3 initialize_db.py
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Database initialization failed"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Quality App v2 is ready to start!"
|
||||
|
||||
# Test Flask app import first
|
||||
python3 << 'PYEOF'
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, '/app')
|
||||
try:
|
||||
from app import create_app
|
||||
print("✓ Flask app imports successfully")
|
||||
app = create_app()
|
||||
print("✓ Flask app created successfully")
|
||||
except Exception as e:
|
||||
print(f"✗ Error loading Flask app: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
PYEOF
|
||||
|
||||
# Execute the main command
|
||||
exec "$@"
|
||||
Reference in New Issue
Block a user