# Basis: offizielles Python-Image (slim, klein & aktuell)
FROM python:3.13-slim

# Keinen .pyc-Cache, sauberes Verhalten in Containern
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1

WORKDIR /srv

# Abhängigkeiten zuerst (nutzt Docker-Layer-Caching)
COPY requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt

# Anwendung als Paket „app“ unter /srv/app
COPY . ./app/

# Daten- und TLS-Verzeichnisse (im Betrieb über Volume/Bind-Mount genutzt)
RUN mkdir -p /data /tls

ENV DATABASE_PATH=/data/ausgaben.db

EXPOSE 8443

CMD ["gunicorn", "-c", "app/gunicorn.conf.py", "app.wsgi:app"]