Spaces:
Running
Running
| # Use Python 3.10 slim image for smaller size | |
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install uv | |
| RUN pip install uv | |
| # Copy dependency files first (for better caching) | |
| COPY pyproject.toml ./ | |
| COPY uv.lock ./ | |
| COPY README.md ./ | |
| # Install dependencies using uv (creates .venv) | |
| RUN uv sync --frozen | |
| # Use /tmp for all caches and Streamlit config to avoid permission issues in read-only paths | |
| ENV HOME=/tmp \ | |
| XDG_CACHE_HOME=/tmp/.cache \ | |
| UV_CACHE_DIR=/tmp/.cache/uv \ | |
| PIP_CACHE_DIR=/tmp/.cache/pip \ | |
| HF_HOME=/tmp/.cache/huggingface \ | |
| TRANSFORMERS_CACHE=/tmp/.cache/huggingface/transformers \ | |
| TORCH_HOME=/tmp/.cache/torch \ | |
| STREAMLIT_CONFIG_DIR=/tmp/.streamlit \ | |
| STREAMLIT_BROWSER_GATHER_USAGE_STATS=false | |
| RUN mkdir -p \ | |
| /tmp/.cache/uv \ | |
| /tmp/.cache/pip \ | |
| /tmp/.cache/huggingface/transformers \ | |
| /tmp/.cache/torch \ | |
| /tmp/.streamlit \ | |
| && chmod -R 777 /tmp/.cache /tmp/.streamlit | |
| # Copy application code | |
| COPY src/ ./src/ | |
| COPY app.py ./ | |
| COPY config.toml ./ | |
| # Expose Streamlit port (Hugging Face Spaces uses 7860) | |
| EXPOSE 7860 | |
| # Set environment variables for Streamlit | |
| ENV STREAMLIT_SERVER_PORT=7860 | |
| ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0 | |
| ENV STREAMLIT_SERVER_HEADLESS=true | |
| ENV STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false | |
| # Run the application using the created virtual environment | |
| ENV PATH="/app/.venv/bin:${PATH}" | |
| CMD ["python", "-m", "streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"] |