Spaces:
Sleeping
Sleeping
File size: 1,294 Bytes
66a0674 | 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 39 40 41 42 43 44 45 46 47 48 | FROM python:3.11-slim
# Installer Poetry et les dépendances système pour SQLite
RUN apt-get update && apt-get install -y \
sqlite3 \
libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/* \
&& pip install poetry
# Configuration Poetry
ENV POETRY_NO_INTERACTION=1 \
POETRY_VENV_IN_PROJECT=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache \
VIRTUAL_ENV=/code/.venv \
PATH="/code/.venv/bin:$PATH"
WORKDIR /code
# Copier les fichiers de dépendances
COPY pyproject.toml poetry.lock ./
# Copier le code source d'abord
COPY . .
# Configurer Poetry pour créer le venv dans le projet
RUN poetry config virtualenvs.in-project true && \
poetry install --only main --no-interaction --no-ansi
# Installer toutes les dépendances et le projet
#RUN poetry install --only=main && rm -rf $POETRY_CACHE_DIR
# Configuration pour SQLite et HuggingFace Spaces
ENV DATABASE_URL="sqlite:///:memory:" \
ENVIRONMENT="production" \
PORT=7860
ENV ML_MODEL_PATH=../model/model.pkl
# Exposer le port requis par HF Spaces
EXPOSE 7860
# Rendre le script d'initialisation exécutable
RUN chmod +x init_db.py
# Commande de démarrage avec initialisation de la base
CMD ["sh", "-c", " poetry env activate && cd src && poetry run uvicorn project5.main:app --host 0.0.0.0 --port 7860"]
|