FROM python:3.11-slim AS builder
RUN apt-get update && apt-get install -y --no-install-recommends gcc libc6-dev && rm -rf /var/lib/apt/lists/*
COPY requirements-production.txt /tmp/requirements.txt
RUN pip wheel --wheel-dir /wheels -r /tmp/requirements.txt
FROM python:3.11-slim
COPY --from=builder /wheels /wheels
RUN pip install --no-cache-dir /wheels/* && rm -rf /wheels && useradd --create-home app
WORKDIR /app
COPY server.py wsgi.py index.html zet.js ./
COPY ephe ./ephe
COPY source.zip LICENSE NOTICE.txt ./
USER app
EXPOSE 8000
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--workers", "2", "--worker-class", "gthread", "--threads", "4", "--timeout", "30", "--max-requests", "1000", "--max-requests-jitter", "100", "wsgi:application"]
