PAM-UmiNur / Dockerfile
pythonprincess's picture
Upload 14 files
7ed2180 verified
# PAM Dockerfile - Optimized for Hugging Face Spaces (CPU)
FROM python:3.10-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
DEBIAN_FRONTEND=noninteractive
# Set working directory
WORKDIR /app
# Install system dependencies for scientific computing (optimized for size)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first (better layer caching)
COPY requirements.txt .
# Install Python dependencies with optimizations
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create data directory if it doesn't exist
RUN mkdir -p /app/data
# Set proper permissions
RUN chmod -R 755 /app
# Health check for container orchestration
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Expose port (Hugging Face Spaces default)
EXPOSE 7860
# Start the FastAPI app using Uvicorn with production settings
CMD ["uvicorn", "api_service:app", \
"--host", "0.0.0.0", \
"--port", "7860", \
"--workers", "1", \
"--log-level", "info", \
"--access-log", \
"--timeout-keep-alive", "75"]