FROM python:3.11-slim WORKDIR /app RUN apt-get update && apt-get install -y build-essential && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY src/ src/ COPY migrations/ migrations/ COPY entrypoint.sh /app/entrypoint.sh RUN mkdir -p data RUN mkdir -p data/flask_sessions RUN chmod +x /app/entrypoint.sh EXPOSE 7860 # Use entrypoint script to run migrations before starting Gunicorn # Run with single worker to fix OAuth session persistence # TODO: Implement server-side session storage (Redis/Memcached) for multi-worker support # Increase timeout to 120s to handle slow LLM responses ENTRYPOINT ["/app/entrypoint.sh"]