#!/usr/bin/env bash # MOD-OSINT Docker entrypoint — startup self-check + Streamlit launch set -euo pipefail PORT="${STREAMLIT_PORT:-7860}" HOST="${STREAMLIT_HOST:-0.0.0.0}" if ! [[ "$PORT" =~ ^[0-9]+$ ]] || [ "$PORT" -lt 1 ] || [ "$PORT" -gt 65535 ]; then echo "[fatal] Invalid STREAMLIT_PORT: ${PORT}" >&2 exit 1 fi required_files=( "gui/streamlit_app.py" "engine/pipeline_orchestrator.py" "requirements-hf.txt" ) for file_path in "${required_files[@]}"; do if [ ! -f "$file_path" ]; then echo "[fatal] Missing required file: $file_path" >&2 exit 1 fi done for dir_path in runs logs; do mkdir -p "$dir_path" if [ ! -w "$dir_path" ]; then echo "[fatal] Directory not writable: $dir_path" >&2 exit 1 fi done python3 - <<'PY' import importlib import sys print(f"[startup] Python: {sys.version.split()[0]}") for mod in ("streamlit", "pandas", "yaml"): importlib.import_module(mod) print("[startup] Dependency import check: OK") PY echo "════════════════════════════════════════════════════════" echo " MOD-OSINT | Streamlit GUI" echo " Binding: ${HOST}:${PORT}" echo " Health URL: http://localhost:${PORT}/_stcore/health" echo "════════════════════════════════════════════════════════" if [ "${MODOSINT_STARTUP_CHECK_ONLY:-0}" = "1" ]; then echo "[startup] MODOSINT_STARTUP_CHECK_ONLY=1 -> exiting after checks" exit 0 fi exec streamlit run gui/streamlit_app.py \ --server.address="${HOST}" \ --server.port="${PORT}" \ --server.enableCORS=false \ --server.enableXsrfProtection=false \ --server.headless=true \ --browser.gatherUsageStats=false