Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +35 -38
Dockerfile
CHANGED
|
@@ -1,53 +1,50 @@
|
|
| 1 |
-
#
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
|
| 21 |
-
# Ajout au PATH pour que la commande 'poetry' soit toujours trouvée.
|
| 22 |
-
ENV PATH="/root/.local/bin:${PATH}"
|
| 23 |
-
|
| 24 |
-
# ---- Étape 3: Installation des dépendances système ----
|
| 25 |
-
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 26 |
git \
|
| 27 |
postgresql-client \
|
| 28 |
libpq-dev \
|
| 29 |
build-essential \
|
| 30 |
-
&&
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
# On définit le répertoire de travail final UNE SEULE FOIS.
|
| 34 |
WORKDIR /app
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
RUN git clone
|
| 38 |
|
| 39 |
-
#
|
| 40 |
-
# On installe poetry globalement.
|
| 41 |
RUN pip install --no-cache-dir poetry
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
#
|
| 45 |
-
RUN
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
|
|
|
|
|
|
|
| 49 |
ENV PORT=7860
|
|
|
|
| 50 |
|
| 51 |
-
#
|
| 52 |
-
|
| 53 |
-
CMD ["/app/packages/python/.venv/bin/python", "-m", "sim.main"]
|
|
|
|
| 1 |
+
# Use an official Python runtime as a base image
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
# Set build-time arguments for environment variables (if needed)
|
| 5 |
+
ARG MODEL_REPO_NAME
|
| 6 |
+
|
| 7 |
+
# Configure environment variables for Python and Poetry
|
| 8 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 9 |
+
PIP_NO_CACHE_DIR=on \
|
| 10 |
+
PIP_DISABLE_PIP_VERSION_CHECK=on \
|
| 11 |
+
POETRY_NO_INTERACTION=1 \
|
| 12 |
+
POETRY_VIRTUALENVS_IN_PROJECT=true \
|
| 13 |
+
POETRY_VIRTUALENVS_CREATE=true \
|
| 14 |
+
PATH="/app/.venv/bin:$PATH"
|
| 15 |
+
|
| 16 |
+
# Install system dependencies and create a non-root user
|
| 17 |
+
RUN set -ex \
|
| 18 |
+
&& apt-get update \
|
| 19 |
+
&& apt-get install -y --no-install-recommends \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
git \
|
| 21 |
postgresql-client \
|
| 22 |
libpq-dev \
|
| 23 |
build-essential \
|
| 24 |
+
&& apt-get clean \
|
| 25 |
+
&& rm -rf /var/lib/apt/lists/* \
|
| 26 |
+
&& addgroup --system --gid 1001 appgroup \
|
| 27 |
+
&& adduser --system --uid 1001 --gid 1001 --no-create-home appuser
|
| 28 |
|
| 29 |
+
# Set the working directory
|
|
|
|
| 30 |
WORKDIR /app
|
| 31 |
|
| 32 |
+
# Clone your repository (consider using COPY for better caching)
|
| 33 |
+
RUN git clone https://github.com/simstudioai/sim ./
|
| 34 |
|
| 35 |
+
# Install Poetry
|
|
|
|
| 36 |
RUN pip install --no-cache-dir poetry
|
| 37 |
|
| 38 |
+
# Install Python dependencies using Poetry
|
| 39 |
+
# Navigate to the correct directory that contains pyproject.toml
|
| 40 |
+
RUN cd /app/packages/python && poetry install --no-dev --no-root
|
| 41 |
|
| 42 |
+
# Switch to the non-root user for security
|
| 43 |
+
USER appuser
|
| 44 |
+
|
| 45 |
+
# Expose the port Hugging Face Spaces expects (default is 7860)
|
| 46 |
ENV PORT=7860
|
| 47 |
+
EXPOSE 7860
|
| 48 |
|
| 49 |
+
# Run your application
|
| 50 |
+
CMD ["python", "-m", "sim.main"]
|
|
|