# Pflanzendoktor-API aus Kapitel 18 (KI-Anwendungen programmieren für Dummies)
#
# Bauen:   docker build -t pflanzendoktor .
# Starten: docker run -p 8000:8000 pflanzendoktor
# Testen:  curl http://localhost:8000/health

# Basis: schlankes Linux mit Python 3.12
FROM python:3.12-slim

WORKDIR /app

# Abhängigkeiten zuerst (bessere Cache-Nutzung beim Neubau)
COPY requirements.txt .
RUN pip install --no-cache-dir torch torchvision \
        --index-url https://download.pytorch.org/whl/cpu \
    && pip install --no-cache-dir -r requirements.txt

# Code in das Image kopieren
COPY app.py .

# Lebenszeichen-Check für Docker und Co.
HEALTHCHECK CMD python -c "import urllib.request; \
    urllib.request.urlopen('http://localhost:8000/health')" || exit 1

# Startbefehl des Containers
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
