# Use a slimmer official Python image FROM python:3.9-slim # Set working directory WORKDIR /app # Install system dependencies for PyPDF2, python-pptx, etc. RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ python3-dev \ && rm -rf /var/lib/apt/lists/* # Copy requirements file COPY requirements.txt . # Add flask-cors to requirements if not already there RUN grep -q "flask-cors" requirements.txt || echo "flask-cors" >> requirements.txt # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Create a non-root user to run the application RUN useradd -m appuser RUN mkdir -p /app/uploads /app/temp && chown -R appuser:appuser /app # Copy the entire application COPY --chown=appuser:appuser . . # Switch to the non-root user USER appuser # Expose the application port EXPOSE 7860 # Run Gunicorn with logging CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0:7860", "--log-level", "info", "--timeout", "120", "app:app"]