# Use Python 3.12 as specified FROM python:3.12-slim # Install minimal system dependencies including git-lfs for database files RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ && rm -rf /var/lib/apt/lists/* # Create a non-root user RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Set working directory WORKDIR /app # Copy requirements first for better Docker layer caching COPY --chown=user ./requirements.txt requirements.txt # Install Python dependencies RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir --upgrade -r requirements.txt # Copy the application code COPY --chown=user . /app # Make startup script executable RUN chmod +x startup.sh # Expose the port that HF Spaces requires EXPOSE 7860 # Set environment variables ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 # Health check HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 # Run the application with LFS data download CMD ["./startup.sh"]