mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-02 18:51:31 +08:00
- Fix nginx config to use keepalive with upstream (was sending Connection: close which caused premature connection closure) - Add _safe_write() to handle socket errors (EPIPE, ECONNRESET, ENOTCONN) gracefully when client disconnects - Fix ASGI scope server/client to always be 2-tuples for IPv6 compatibility (IPv6 sockets return 4-tuples) - Add write_eof() before close() to ensure buffered data is flushed - Bind to [::] for dual-stack IPv4/IPv6 support in test containers
56 lines
1.5 KiB
Docker
56 lines
1.5 KiB
Docker
FROM python:3.12-slim
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy the gunicorn source code and install it with all extras
|
|
COPY . /gunicorn-src/
|
|
RUN pip install --no-cache-dir /gunicorn-src/[http2,testing]
|
|
|
|
# Install additional ASGI frameworks for testing
|
|
RUN pip install --no-cache-dir \
|
|
starlette>=0.35.0 \
|
|
fastapi>=0.109.0 \
|
|
websockets>=12.0
|
|
|
|
# Copy the test applications
|
|
COPY tests/docker/asgi_compliance/apps /app/apps
|
|
|
|
# Create entrypoint script
|
|
RUN echo '#!/bin/bash\n\
|
|
set -e\n\
|
|
\n\
|
|
if [ "$USE_SSL" = "1" ]; then\n\
|
|
exec gunicorn "apps.main_app:app" \\\n\
|
|
--bind "[::]:8443" \\\n\
|
|
--worker-class "asgi" \\\n\
|
|
--workers 2 \\\n\
|
|
--worker-connections 1000 \\\n\
|
|
--certfile "/certs/server.crt" \\\n\
|
|
--keyfile "/certs/server.key" \\\n\
|
|
--asgi-disconnect-grace-period 0 \\\n\
|
|
--log-level "debug" \\\n\
|
|
--access-logfile "-" \\\n\
|
|
--error-logfile "-"\n\
|
|
else\n\
|
|
exec gunicorn "apps.main_app:app" \\\n\
|
|
--bind "[::]:8000" \\\n\
|
|
--worker-class "asgi" \\\n\
|
|
--workers 2 \\\n\
|
|
--worker-connections 1000 \\\n\
|
|
--asgi-disconnect-grace-period 0 \\\n\
|
|
--log-level "debug" \\\n\
|
|
--access-logfile "-" \\\n\
|
|
--error-logfile "-"\n\
|
|
fi\n\
|
|
' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
|
|
|
|
EXPOSE 8000 8443
|
|
|
|
CMD ["/app/entrypoint.sh"]
|