Spaces:
Sleeping
Sleeping
File size: 990 Bytes
ab063c7 d5c6eb0 ab063c7 d5c6eb0 ab063c7 d5c6eb0 ab063c7 d5c6eb0 ab063c7 d5c6eb0 ab063c7 d5c6eb0 ab063c7 d5c6eb0 ab063c7 d5c6eb0 ab063c7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | # Kleines Image als Basis
FROM python:3.9-slim
# Verhindert Python-Buffering (Logs erscheinen sofort)
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PORT=7860
# System-Abhängigkeiten
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Arbeitsverzeichnis
WORKDIR /app
# User anlegen (Hugging Face Default: User 1000)
RUN useradd -m -u 1000 user
# Requirements kopieren und installieren
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Den restlichen Code kopieren und Besitzer anpassen
COPY --chown=user:user . .
# Zum User wechseln
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# Port freigeben
EXPOSE 7860
# Startbefehl via Gunicorn (mit Uvicorn-Workern)
# Das ist der Gold-Standard für FastAPI Deployments
CMD ["gunicorn", "-w", "4", "-k", "uvicorn.workers.UvicornWorker", "main:app", "--bind", "0.0.0.0:7860", "--timeout", "120"] |