FROM python:3.12-slim # Set working directory WORKDIR /app # Install uv COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv # Copy dependency files first for better caching COPY pyproject.toml uv.lock* ./ # Copy the entire project COPY . . # Set UV cache directory to a writable location ENV UV_CACHE_DIR=/tmp/uv-cache ENV HOME=/tmp # Install dependencies with uv RUN uv sync --frozen --no-dev # Create cache directory and set permissions RUN mkdir -p /tmp/uv-cache && chmod -R 777 /tmp/uv-cache # Make /app directory writable for non-root users (required for HuggingFace Spaces) RUN chmod -R 777 /app # Expose Streamlit port EXPOSE 8501 # Set environment variables for Streamlit ENV STREAMLIT_SERVER_PORT=8501 ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0 ENV STREAMLIT_SERVER_HEADLESS=true ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false # Run Streamlit app CMD ["uv", "run", "streamlit", "run", "apps/streamlit_ui/main.py"]