# Use Python 3.13 slim image FROM python:3.13-slim # Set working directory WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ poppler-utils \ libreoffice \ ffmpeg \ libmagic1 \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Copy and set permissions for entrypoint script COPY docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh # Create directories for uploads and database RUN mkdir -p app/static/uploads instance # Set environment variables ENV FLASK_APP=app.app:create_app ENV PYTHONUNBUFFERED=1 ENV FLASK_ENV=production # Expose port EXPOSE 5000 # Create a non-root user RUN useradd -m -u 1000 appuser && \ chown -R appuser:appuser /app /docker-entrypoint.sh USER appuser # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:5000/').read()" || exit 1 # Run the application via entrypoint ENTRYPOINT ["/docker-entrypoint.sh"]