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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user