feat: add containerization support

- Add Containerfile with multi-stage build for minimal image
- Add .containerignore to exclude unnecessary files
- Add /health endpoint for container health checks
- Update main.py to expose Flask app for gunicorn

Uses Python 3.12-slim base, runs as non-root user, exposes port 8000.
This commit is contained in:
2025-12-22 13:10:47 -07:00
parent e8e30442d8
commit 6dbc84a04c
4 changed files with 116 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
"""Setup route for initial admin account creation."""
from flask import Blueprint, abort, redirect, render_template, session, url_for
from flask import Blueprint, abort, jsonify, redirect, render_template, session, url_for
from src.app import bcrypt, db
from src.forms import SetupForm
@@ -9,6 +9,21 @@ from src.models import Admin
setup_bp = Blueprint("setup", __name__)
@setup_bp.route("/health")
def health():
"""Health check endpoint for container orchestration.
Returns:
JSON response with health status.
"""
try:
# Check database connectivity
db.session.execute(db.text("SELECT 1"))
return jsonify({"status": "healthy", "database": "connected"}), 200
except Exception as e:
return jsonify({"status": "unhealthy", "error": str(e)}), 503
@setup_bp.route("/setup", methods=["GET", "POST"])
def setup():
"""Handle initial admin account setup.