Add self-contained Docker deployment for EasyPanel / docker-compose: - Dockerfile: python:3.11-slim + nginx. Serves the PREBUILT Vue SPA (frontend/dist, committed) via nginx and reverse-proxies /api to the Flask backend on 127.0.0.1:5000. No node/npm in the image (avoids Vite/npm flakiness in Docker builds). VOLUME /app/backend/data for persistence (factor vintages, dividend ledger, forward runs, prices). HEALTHCHECK hits /api/v1/dashboard/summary. Exposes :80. - deploy/nginx.conf: SPA fallback + /api proxy to 127.0.0.1:5000 + gzip. - deploy/entrypoint.sh: starts Flask (HOST=0.0.0.0:5000) + nginx foreground, forwards signals. - docker-compose.yml: single service 'set50', port 8080:80, mounts ./backend/data for persistence, healthcheck. - .dockerignore excludes .git/.venv/backend/data/node_modules/docs. - .gitignore now tracks frontend/dist/ (prebuilt bundle required by the image); backend/data stays untracked. - Backend runtime verified: test_client GET /api/v1/dashboard/summary=200 (the HEALTHCHECK path). entrypoint sh -n, compose YAML parse, and all Dockerfile-referenced files exist. NOTE: no local docker here, so the image itself was not built — that happens on EasyPanel.
27 lines
777 B
Bash
27 lines
777 B
Bash
#!/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
|