FROM python:3.10-slim # Create app user RUN useradd -m -u 1000 user WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ git \ build-essential \ libpq-dev \ && rm -rf /var/lib/apt/lists/* # Copy requirements and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Download required NLTK data RUN python -m nltk.downloader -d /usr/local/share/nltk_data punkt stopwords # Create cache directories with proper permissions RUN mkdir -p /app/.cache && chown -R user:user /app/.cache # Copy application code COPY --chown=user:user app/ ./app/ COPY --chown=user:user main.py . COPY --chown=user:user main_simple.py . COPY --chown=user:user main_full.py . # Switch to user USER user # Set environment variables ENV TRANSFORMERS_CACHE=/app/.cache/huggingface ENV HF_HOME=/app/.cache/huggingface ENV PYTHONUNBUFFERED=1 # Expose port EXPOSE 7860 # Run the application (using full version with on-demand loading) CMD ["uvicorn", "main_full:app", "--host", "0.0.0.0", "--port", "7860"]