dockerized läuft

This commit is contained in:
br committed 2026-08-03 13:38:11 +02:00
1 parent a8c95e9df5
commit 1c789aa8d5
10 files changed
+735 -286

No files matched your search

Executable
+54
View File
@@ -0,0 +1,54 @@
#!/bin/bash
# =============================================================================
# Formeleon - Entrypoint Script
# Author: Björn Runden <br@runden.net>
# Description: Entrypoint script for Docker containers.
# =============================================================================
set -e
APP_NAME="formeleon"
log_info() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] [INFO] [${APP_NAME}] $1"
}
log_error() {
echo "[$(date +'%Y-%m-%d %H:%M:%S')] [ERROR] [${APP_NAME}] $1" >&2
}
# If the first argument is a known flask or system command, run it directly
if [ "$1" = "flask" ] || [ "$1" = "bash" ] || [ "$1" = "sh" ] || [ "$1" = "python" ]; then
log_info "Executing command: $*"
exec "$@"
fi
# If the user passed "server" (default from Dockerfile CMD), start the app
if [ "$1" = "server" ]; then
# Optional DB Migration check on startup for Dev Mode (convenience)
if [ "${DEV_MODE:-false}" = "true" ] || [ "${FLASK_ENV:-development}" = "development" ]; then
log_info "Development mode detected. Ensuring DB schema is up to date..."
# Initialize migrations if folder doesn't exist
if [ ! -d "migrations" ]; then
log_info "Initializing migrations..."
flask db init
fi
# Always try to upgrade to latest
flask db upgrade || log_error "Failed to upgrade DB, skipping."
fi
# Start the actual server
if [ "${FLASK_ENV:-development}" = "development" ]; then
log_info "Starting Flask development server with hot reload..."
exec flask run --host=0.0.0.0 --port=5000 --debug
else
log_info "Starting Gunicorn production server..."
exec gunicorn --bind 0.0.0.0:5000 --workers 4 --threads 2 --worker-class gthread app:app
fi
fi
# Fallback: just execute whatever was passed
exec "$@"