Erstumsetzung: OAMC Turnierauswertung (AP 0–7, 9)
* Datenmodell + Alembic-Initialmigration (Plan §4), Seed Saison 2026 * Wertungs-Engine (Plan §3.3), regelbasiert je Kategorie/Saison - Abnahmetest gegen die Ergebnisliste 2026-05-31 * Meisterschaftsberechnung mit Streichresultaten + Tie-Break (PLATZHALTER-Punktetabelle, O-1 offen) * Ingest-API (idempotent, dry_run) inkl. Excel-Leser und Fahrer-Matching/Merge * Zeitmessungs-Endpoint (Batch, idempotent, unzugeordnet/unplausibel) + SSE-Anzeige - Mess-Pi-Client bewusst NICHT enthalten (docs/zeitmessung-endpoint.md) * Frontend: öffentliche Seiten + internes Backend (Jinja2/HTMX, kein Build) * Auslieferung: Docker (multi-arch) + docker-compose sowie Debian-Paket/APT-Repo * 57 Tests grün gegen echte PostgreSQL-Testdatenbank Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
# OAMC Turnierauswertung — Anwendungs-Image
|
||||
# Multi-Arch: baut fuer linux/arm64 (Raspberry Pi 4) und linux/amd64.
|
||||
# docker buildx build --platform linux/arm64,linux/amd64 -f docker/Dockerfile .
|
||||
|
||||
FROM python:3.12-slim AS build
|
||||
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 PIP_NO_CACHE_DIR=1
|
||||
WORKDIR /app
|
||||
|
||||
# WeasyPrint (PDF-Export) braucht native Bibliotheken; Build-Tools nur hier.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential libpq-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY pyproject.toml README.md ./
|
||||
COPY src ./src
|
||||
RUN python -m venv /opt/venv \
|
||||
&& /opt/venv/bin/pip install --upgrade pip \
|
||||
&& /opt/venv/bin/pip install .
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
FROM python:3.12-slim AS runtime
|
||||
ENV PYTHONUNBUFFERED=1 PATH="/opt/venv/bin:$PATH" \
|
||||
OAMC_UPLOAD_DIR=/var/oamc/uploads
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
libpq5 libpango-1.0-0 libpangoft2-1.0-0 libcairo2 \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& useradd --system --create-home --uid 10001 oamc \
|
||||
&& mkdir -p /var/oamc/uploads && chown -R oamc:oamc /var/oamc
|
||||
|
||||
COPY --from=build /opt/venv /opt/venv
|
||||
COPY src ./src
|
||||
COPY migrations ./migrations
|
||||
COPY alembic.ini ./
|
||||
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
USER oamc
|
||||
EXPOSE 8000
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s \
|
||||
CMD python -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8000/healthz').status==200 else 1)"
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
CMD ["uvicorn", "oamc.main:app", "--host", "0.0.0.0", "--port", "8000", "--proxy-headers"]
|
||||
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
# Wartet auf die DB, spielt Migrationen ein, optional Seed, startet dann das CMD.
|
||||
set -eu
|
||||
|
||||
echo "[entrypoint] warte auf Datenbank ..."
|
||||
python - <<'PY'
|
||||
import os, time, sys
|
||||
import psycopg
|
||||
url = os.environ.get("OAMC_DATABASE_URL", "")
|
||||
dsn = url.replace("postgresql+psycopg://", "postgresql://", 1)
|
||||
for i in range(60):
|
||||
try:
|
||||
psycopg.connect(dsn, connect_timeout=3).close()
|
||||
print("[entrypoint] DB erreichbar")
|
||||
sys.exit(0)
|
||||
except Exception as e: # noqa
|
||||
print(f"[entrypoint] ({i+1}/60) noch nicht bereit: {e}")
|
||||
time.sleep(2)
|
||||
sys.exit("[entrypoint] DB nicht erreichbar")
|
||||
PY
|
||||
|
||||
echo "[entrypoint] alembic upgrade head"
|
||||
alembic upgrade head
|
||||
|
||||
if [ "${OAMC_SEED_ON_START:-0}" = "1" ]; then
|
||||
echo "[entrypoint] Seed Saison 2026 (idempotent)"
|
||||
oamc-turnier seed || echo "[entrypoint] Seed uebersprungen/fehlgeschlagen"
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
@@ -0,0 +1,40 @@
|
||||
# nginx vor uvicorn: TLS-Terminierung (im Compose ohne TLS), statische Dateien,
|
||||
# SSE-taugliches Proxying (kein Buffering, lange Timeouts).
|
||||
|
||||
upstream oamc_app { server app:8000; }
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
client_max_body_size 25m;
|
||||
charset utf-8;
|
||||
|
||||
location /static/ {
|
||||
proxy_pass http://oamc_app;
|
||||
proxy_cache_valid 200 10m;
|
||||
expires 1h;
|
||||
}
|
||||
|
||||
# Server-Sent Events: Puffern aus, Verbindung offen halten
|
||||
location /api/v1/turniere/aktiv/anzeige {
|
||||
proxy_pass http://oamc_app;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Connection "";
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
location / {
|
||||
proxy_pass http://oamc_app;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user