Spaces:
Sleeping
Sleeping
File size: 993 Bytes
ea130a9 ef040c3 7ad8b08 ea130a9 7ad8b08 ea130a9 7ad8b08 ea130a9 7ad8b08 ea130a9 7ad8b08 | 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 37 38 | FROM python:3.12-slim
ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PORT=7860
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# Créer l'utilisateur exigé par Spaces et passer en non-root
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
# Installer Poetry
RUN pip install --no-cache-dir "poetry==1.8.3" && poetry --version
COPY --chown=user pyproject.toml poetry.lock* /app/
# Création env poetry
RUN poetry config virtualenvs.create true \
&& poetry config virtualenvs.in-project true \
&& poetry install --no-interaction --no-ansi --only main
# Ajouter le venv au PATH pour trouver uvicorn/python
ENV PATH="/app/.venv/bin:$PATH"
# Copier le code
COPY --chown=user src /app/src
EXPOSE 7860
# Lancer FastAPI
CMD ["uvicorn", "main:app", "--app-dir", "src", "--host", "0.0.0.0", "--port", "7860"]
|