Spaces:
Sleeping
Sleeping
| FROM python:3.11-slim | |
| ENV PYTHONIOENCODING=utf-8 \ | |
| PYTHONUTF8=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PIP_DISABLE_PIP_VERSION_CHECK=1 | |
| WORKDIR /app | |
| # System deps: | |
| # - build-essential + libffi-dev: build native extensions for `cryptography` | |
| # - coreutils + xxd: built-in CLI tools the terminal sandbox shells out to | |
| # - Removed curl (security risk - not needed at runtime) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| libffi-dev \ | |
| coreutils \ | |
| xxd \ | |
| ca-certificates \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create non-root user for security | |
| RUN useradd --create-home --shell /bin/bash --uid 1000 appuser && \ | |
| mkdir -p /app /tmp/sandbox && \ | |
| chown -R appuser:appuser /app /tmp/sandbox | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| COPY --chown=appuser:appuser . . | |
| # Switch to non-root user | |
| USER appuser | |
| # Hugging Face Spaces default. The proxy forwards public 7860 → container 7860. | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # uvicorn binds 0.0.0.0:$PORT (see main.py). 2 workers so HF proxy can hot-reload | |
| # one watcher task while the other serves HTTP. | |
| CMD ["python", "main.py"] | |