Spaces:
Build error
Build error
| # Use an official Python runtime as a base image | |
| FROM python:3.11-slim | |
| # Set build-time arguments for environment variables (if needed) | |
| ARG MODEL_REPO_NAME | |
| # Configure environment variables for Python and Poetry | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=on \ | |
| PIP_DISABLE_PIP_VERSION_CHECK=on \ | |
| POETRY_NO_INTERACTION=1 \ | |
| POETRY_VIRTUALENVS_IN_PROJECT=true \ | |
| POETRY_VIRTUALENVS_CREATE=true \ | |
| PATH="/app/.venv/bin:$PATH" | |
| # Install system dependencies and create a non-root user | |
| RUN set -ex \ | |
| && apt-get update \ | |
| && apt-get install -y --no-install-recommends \ | |
| git \ | |
| postgresql-client \ | |
| libpq-dev \ | |
| build-essential \ | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* \ | |
| && addgroup --system --gid 1001 appgroup \ | |
| && adduser --system --uid 1001 --gid 1001 --no-create-home appuser | |
| # Set the working directory | |
| WORKDIR /app | |
| # Clone your repository (consider using COPY for better caching) | |
| RUN git clone https://github.com/simstudioai/sim ./ | |
| # Install Poetry | |
| RUN pip install --no-cache-dir poetry | |
| # Install Python dependencies using Poetry | |
| # Navigate to the correct directory that contains pyproject.toml | |
| RUN cd /app/packages/python && poetry install --no-dev --no-root | |
| # Switch to the non-root user for security | |
| USER appuser | |
| # Expose the port Hugging Face Spaces expects (default is 7860) | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Run your application | |
| CMD ["python", "-m", "sim.main"] |