- App_Server/Dockerfile: Build-Context auf Repo-Root, COPY-Pfade angepasst, ENTRYPOINT aktiviert, dev-Stage mit inittypescriptdev.sh - NGINX_Server/Dockerfile: Multi-Stage mit frontend-Stage (Node.js baut TypeScript), statische Dateien und Config-Templates ins Image kopiert - docker-compose.base.yaml: Context auf '.', python-venv Volume entfernt, NGINX_STATIC_DIR/CONFIG_TEMPLATE_DIR bind-mounts in Dev verschoben - docker-compose.dev.yaml: python-venv-dev Volume, APP_DEBUG=true, nginx-proxy mit bind-mounts fuer statische Dateien und Templates - docker-compose.prod.yaml: Code-bind-mount entfernt, nginx-proxy extends - approot.py: absolute Pfade, Debug-Modus via APP_DEBUG Umgebungsvariable - init.sh: vereinfacht (kein cd/pip, absolute Pfade) - inireader.mjs: absoluter Pfad fuer config.ini - package.json: scripts.build (tsc + rollup) ergaenzt - .dockerignore, deploy-kbcrm-test.sh, deploy-kbcrm-prod.sh erstellt - docker-compose.save.yaml geloescht - env-sample: BUILD_ENVIRONMENT nach oben, Dev-only Variablen markiert Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
65 lines
2.4 KiB
Python
65 lines
2.4 KiB
Python
from flask import Flask, jsonify
|
|
from flask_login import LoginManager
|
|
from settings import Configuration
|
|
from db import dbauth
|
|
from db import dbapp
|
|
from auth.model.checkdb import checkupdates as checkupdatesauth
|
|
import os
|
|
|
|
login_manager = LoginManager()
|
|
|
|
|
|
def init_app():
|
|
app = Flask(__name__)
|
|
|
|
config: Configuration = Configuration("/usr/opt/pythonapp/App_Server/root/config.ini")
|
|
_projektname = config.app_projectname
|
|
|
|
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:////usr/var/pythonappdb/{}.db".format(_projektname)
|
|
app.config["SQLALCHEMY_BINDS"] = {
|
|
"auth": "sqlite:////usr/var/pythonappdb/auth.db",
|
|
"appdb": "sqlite:////usr/var/pythonappdb/{}.db".format(_projektname)
|
|
}
|
|
app.config["DEBUG"] = os.environ.get("APP_DEBUG", "false").lower() in ("true", "1", "yes")
|
|
app.config["PROJEKTNAME"] = config.app_projectname
|
|
app.config["APPID"] = config.app_appid
|
|
app.config["APPVERSION"] = config.clientapp_version
|
|
app.config["SECRET_KEY"] = config.flask_secret
|
|
|
|
# Initialize Plugins
|
|
# dbapp ist dasselbe Objekt wie dbauth (siehe db.py); beide teilen sich
|
|
# die SQLAlchemy-Registry. Daher genügt ein einziger init_app-Aufruf, der
|
|
# sowohl den auth- als auch den appdb-Bind initialisiert.
|
|
login_manager.init_app(app)
|
|
dbauth.init_app(app)
|
|
|
|
# Globale Fehlerbehandlung für ApplicationExceptionen. Die Route-internen
|
|
# try/except-Blöcke (auth) fangen weiterhin lokal ab; für alle nicht
|
|
# gefangenen Fälle (insbesondere crm) greift dieser Handler.
|
|
from auth.model.errors import ApplicationError, AutorisationError
|
|
|
|
@app.errorhandler(ApplicationError)
|
|
def handle_application_error(ex):
|
|
return jsonify(ex.error), ex.htmlstatus
|
|
|
|
@app.errorhandler(AutorisationError)
|
|
def handle_autorisation_error(ex):
|
|
return jsonify(ex.error), ex.htmlstatus
|
|
|
|
with app.app_context():
|
|
# Include our Routes
|
|
print("before auth.routes", flush=True)
|
|
from auth import routes
|
|
from routes import general
|
|
from crm import routes as crm_routes
|
|
from crm.model import checkdb as crm_checkdb
|
|
checkupdatesauth()
|
|
crm_checkdb.checkupdates()
|
|
|
|
# Flask CLI-Befehle (init-db, reset-db) registrieren
|
|
from cli import register_cli_commands
|
|
register_cli_commands(app)
|
|
|
|
return app
|
|
|