| 1 |
FROM python:3.14-slim |
| 2 |
|
| 3 |
# Install build dependencies |
| 4 |
RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 5 |
gcc \ |
| 6 |
curl \ |
| 7 |
&& rm -rf /var/lib/apt/lists/* |
| 8 |
|
| 9 |
WORKDIR /app |
| 10 |
|
| 11 |
# Copy the gunicorn source code and install it with all extras |
| 12 |
COPY . /gunicorn-src/ |
| 13 |
RUN pip install --no-cache-dir /gunicorn-src/[http2,testing] |
| 14 |
|
| 15 |
# Install additional ASGI frameworks for testing |
| 16 |
RUN pip install --no-cache-dir \ |
| 17 |
starlette>=0.35.0 \ |
| 18 |
fastapi>=0.109.0 \ |
| 19 |
websockets>=12.0 |
| 20 |
|
| 21 |
# Copy the test applications |
| 22 |
COPY tests/docker/asgi_compliance/apps /app/apps |
| 23 |
|
| 24 |
# Create entrypoint script |
| 25 |
RUN echo '#!/bin/bash\n\ |
| 26 |
set -e\n\ |
| 27 |
\n\ |
| 28 |
if [ "$USE_SSL" = "1" ]; then\n\ |
| 29 |
exec gunicorn "apps.main_app:app" \\\n\ |
| 30 |
--bind "[::]:8443" \\\n\ |
| 31 |
--worker-class "asgi" \\\n\ |
| 32 |
--workers 2 \\\n\ |
| 33 |
--worker-connections 1000 \\\n\ |
| 34 |
--certfile "/certs/server.crt" \\\n\ |
| 35 |
--keyfile "/certs/server.key" \\\n\ |
| 36 |
--asgi-disconnect-grace-period 0 \\\n\ |
| 37 |
--log-level "debug" \\\n\ |
| 38 |
--access-logfile "-" \\\n\ |
| 39 |
--error-logfile "-"\n\ |
| 40 |
else\n\ |
| 41 |
exec gunicorn "apps.main_app:app" \\\n\ |
| 42 |
--bind "[::]:8000" \\\n\ |
| 43 |
--worker-class "asgi" \\\n\ |
| 44 |
--workers 2 \\\n\ |
| 45 |
--worker-connections 1000 \\\n\ |
| 46 |
--asgi-disconnect-grace-period 0 \\\n\ |
| 47 |
--log-level "debug" \\\n\ |
| 48 |
--access-logfile "-" \\\n\ |
| 49 |
--error-logfile "-"\n\ |
| 50 |
fi\n\ |
| 51 |
' > /app/entrypoint.sh && chmod +x /app/entrypoint.sh |
| 52 |
|
| 53 |
EXPOSE 8000 8443 |
| 54 |
|
| 55 |
CMD ["/app/entrypoint.sh"] |