Projekt Setup

This commit is contained in:
Bernhard Kolb 2026-04-14 13:06:15 +02:00
commit cd08781954
5 changed files with 184 additions and 0 deletions

41
.gitignore vendored Normal file
View File

@ -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/

23
Dockerfile Normal file
View File

@ -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"]

32
README.md Normal file
View File

@ -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ü

72
deploy_flask.sh Normal file
View File

@ -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."

16
requirements.txt Normal file
View File

@ -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