commit cd087819549cf95b9a44a6bee39f1c46c6144f00 Author: Bernhard Kolb Date: Tue Apr 14 13:06:15 2026 +0200 Projekt Setup diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f1515bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# Python +__pycache__/ +*.pyc +*.pyo + +# Env / secrets +.env +.env.* +!.env.example + +# Logs +*.log +logs/ +container-logs/ + +# macOS +.DS_Store +._* + + +# VS Code +.vscode/ + +# Runtime data +db/ +pgdata/ +assets/ +data/ +tmp/ + +# OpenProject / Gitea persistent data +infra/openproject/pgdata/ +infra/openproject/assets/ +infra/gitea/data/ + +# Flask runtime +app/flask-postgres/files/uploads/ +app/flask-postgres/files/runtime/ + +# Synology +@eaDir/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ea7b348 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.11-slim + +WORKDIR /app + +# 👉 SYSTEM LIBRARIES für WeasyPrint +RUN apt-get update && apt-get install -y \ + libpango-1.0-0 \ + libpangoft2-1.0-0 \ + libcairo2 \ + libgdk-pixbuf-2.0-0 \ + libffi-dev \ + shared-mime-info \ + fonts-dejavu-core \ + && rm -rf /var/lib/apt/lists/* + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 5000 + +CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--access-logfile", "/logs/gunicorn-access.log", "--error-logfile", "/logs/gunicorn-error.log", "app:app"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..1e82ca5 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# Projekt HebammeKrystyna + +Startgerüst für eine Flask-Anwendung mit: + +Statische Website für Krystyna + +## Start lokal + +```bash +python -m venv .venv +source .venv/bin/activate +pip install -r requirements.txt +export FLASK_APP=app.py +flask run --host=0.0.0.0 --port=5000 +``` + +## Wichtiger Hinweis zum Admin-User + +In `schema.sql` wird der initiale Admin-User mit Passwort `topsecret` als Klartext in `passwort_hash` angelegt, genau wie von dir gewünscht. +In `app.py` ist dafür bereits eine kleine Sonderlogik enthalten: Beim **ersten Login** mit `topsecret` wird dieser Wert automatisch in einen echten Passwort-Hash umgewandelt. Danach läuft der Login normal über Hash-Prüfung. + +## Docker + +Eine Beispiel-Datei liegt in `docker-compose.example.yaml`. + +## Nächste sinnvolle Ausbaustufen + +- echte CRUD-Formulare im Admin-Bereich +- E-Mail-Template für Aktivierung und Ergebnisversand +- Validierung / CSRF-Schutz +- Pagination / Verlauf früherer Assessments +- bessere Rollenprüfung im Menü diff --git a/deploy_flask.sh b/deploy_flask.sh new file mode 100644 index 0000000..7057342 --- /dev/null +++ b/deploy_flask.sh @@ -0,0 +1,72 @@ +#!/bin/bash +set -euo pipefail + +SRC_ROOT="/Volumes/MacBook SD/Projekte/hebammekrystyna" +DST_ROOT="/Volumes/docker/flask-postgres/app-hebammekrystyna" + +NAS_USER="BKolb" +NAS_HOST="192.168.0.10" +CONTAINER_NAME="flask_hebammekrystyna" + +echo "Starte Deployment..." + +[ -d "$SRC_ROOT" ] || { echo "Quelle fehlt: $SRC_ROOT"; exit 1; } +[ -d "$DST_ROOT" ] || { echo "Ziel fehlt: $DST_ROOT"; exit 1; } + +echo "Synchronisiere Projektdateien ..." +rsync -av --delete \ + --exclude '.DS_Store' \ + --exclude '._*' \ + --exclude '__pycache__/' \ + --exclude '*.pyc' \ + --exclude '*.pyo' \ + --exclude '*.log' \ + --exclude '.git/' \ + --exclude '.venv/' \ + --exclude 'venv/' \ + --exclude 'node_modules/' \ + --exclude 'files/' \ + --exclude 'images/' \ + --exclude 'styles/' \ + "$SRC_ROOT/" "$DST_ROOT/" + +echo "Synchronisiere images/ ..." +if [ -d "$SRC_ROOT/images" ]; then + mkdir -p "$DST_ROOT/images" + rsync -av --delete \ + --exclude '.DS_Store' \ + --exclude '._*' \ + --exclude 'videos/' \ + "$SRC_ROOT/images/" "$DST_ROOT/images/" +else + echo "Hinweis: $SRC_ROOT/images nicht gefunden, übersprungen." +fi + +echo "Synchronisiere styles/ ..." +if [ -d "$SRC_ROOT/styles" ]; then + mkdir -p "$DST_ROOT/styles" + rsync -av --delete \ + --exclude '.DS_Store' \ + --exclude '._*' \ + "$SRC_ROOT/styles/" "$DST_ROOT/styles/" +else + echo "Hinweis: $SRC_ROOT/styles nicht gefunden, übersprungen." +fi + +echo "Synchronisiere templates/ ..." +if [ -d "$SRC_ROOT/templates" ]; then + mkdir -p "$DST_ROOT/templates" + rsync -av --delete \ + --exclude '.DS_Store' \ + --exclude '._*' \ + "$SRC_ROOT/templates/" "$DST_ROOT/templates/" +else + echo "Hinweis: $SRC_ROOT/templates nicht gefunden, übersprungen." +fi + +echo "files/ wird bewusst nicht angefasst." + +echo "Container manuell neu starten oder neu bauen falls requirements/Dockerfile geändert wurden." +# ssh "${NAS_USER}@${NAS_HOST}" "/usr/bin/docker restart ${CONTAINER_NAME}" + +echo "Deployment abgeschlossen." \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..05a5640 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,16 @@ +Flask==3.1.0 +psycopg2-binary==2.9.10 +Werkzeug==3.1.3 +itsdangerous==2.2.0 +matplotlib==3.10.1 +gunicorn==23.0.0 + +weasyprint==60.2 +pydyf==0.8.0 +cairocffi==1.6.1 + +Pillow==10.4.0 +qrcode==7.4.2 + +pytest==8.3.2 +python-json-logger==2.0.7 \ No newline at end of file