FROM python:3.10-slim # Create user with UID 1000 for Hugging Face Spaces non-root security RUN useradd -m -u 1000 user WORKDIR /app # Install system dependencies (OpenMP libgomp1 for PyTorch / RDKit) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ curl \ libgomp1 \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy application code, configs, raw data, and checkpoints COPY configs/ ./configs/ COPY data/raw/ ./data/raw/ COPY results/checkpoints/ ./results/checkpoints/ COPY src/ ./src/ COPY app/ ./app/ COPY frontend/dist/ ./frontend/dist/ RUN chown -R user:user /app USER user ENV PORT=8000 \ LOW_MEMORY_MODE=1 \ PYTHONUNBUFFERED=1 EXPOSE 8000 HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ CMD curl -f http://localhost:8000/api/health || exit 1 CMD ["sh", "-c", "uvicorn app.server:app --host 0.0.0.0 --port ${PORT:-8000}"]