#!/usr/bin/env sh set -e # Start the Flask backend on 0.0.0.0:5000 (bind all interfaces so nginx can # proxy to it inside the container). DATA_DIR is /app/backend/data by default # (a mounted volume makes it survive container recreate). cd /app/backend export HOST="${HOST:-0.0.0.0}" export PORT="${PORT:-5000}" export PAPER_BIND_HOST="$HOST" # pid1 helper: run nginx in foreground + Flask subprocess so the container # stays alive and signals are handled. Keep it simple and robust. # Start Flask in the background python run.py & FLASK_PID=$! # Start nginx in the foreground (its own master + workers) nginx -g "daemon off;" & NGINX_PID=$! # forward signals to both and wait trap 'kill $FLASK_PID $NGINX_PID 2>/dev/null || true' INT TERM wait $FLASK_PID wait $NGINX_PID