content: FROM python:3.11-slim
  
  # Set working directory
  WORKDIR /app
  
  # Set environment variables for maximum stability
  ENV PYTHONUNBUFFERED=1
  ENV PYTHONDONTWRITEBYTECODE=1
  ENV TRANSFORMERS_CACHE=/app/cache/transformers
  ENV HF_HOME=/app/cache/huggingface
  ENV TOKENIZERS_PARALLELISM=false
  ENV OMP_NUM_THREADS=1
  ENV MKL_NUM_THREADS=1
  ENV OPENBLAS_NUM_THREADS=1
  ENV NUMEXPR_NUM_THREADS=1
  ENV VECLIB_MAXIMUM_THREADS=1
  
  # Create cache directory
  RUN mkdir -p /app/cache/transformers /app/cache/huggingface
  
  # Install system dependencies
  RUN apt-get update && apt-get install -y \
      curl \
      wget \
      ca-certificates \
      build-essential \
      python3-dev \
      && rm -rf /var/lib/apt/lists/*
  
  # Copy requirements first for better caching
  COPY minimal-requirements.txt requirements.txt
  
  # Install minimal Python dependencies
  RUN pip install --no-cache-dir --upgrade pip && \
      pip install --no-cache-dir -r requirements.txt
  
  # Copy application code
  COPY minimal-main.py main.py
  
  # Expose port
  EXPOSE 7999
  
  # Health check
  HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
      CMD curl -f http://localhost:7999/health || exit 1
  
  # Use direct Flask instead of Gunicorn for maximum stability
  CMD ["python", "main.py"]
  