Debian Codegraph @

examples/celery_alternative/Dockerfile

raw
1 # Dockerfile for Celery Replacement Example
2 #
3 # This demonstrates running a production-ready application with
4 # Gunicorn dirty arbiters replacing Celery for background tasks.
5 #
6 # Key difference from Celery deployment:
7 # - Celery: Needs separate web + worker containers + Redis/RabbitMQ
8 # - Dirty: Single container handles both HTTP and background tasks
9
10 FROM python:3.14-slim
11
12 # Set working directory
13 WORKDIR /app
14
15 # Install system dependencies
16 RUN apt-get update && apt-get install -y --no-install-recommends \
17 curl \
18 && rm -rf /var/lib/apt/lists/*
19
20 # Copy gunicorn source and install (from build context root)
21 COPY . /gunicorn-src
22 RUN pip install --no-cache-dir /gunicorn-src
23
24 # Copy example application
25 COPY examples/celery_alternative /app
26 RUN pip install --no-cache-dir fastapi uvloop requests pytest
27
28 # Environment variables
29 ENV PYTHONUNBUFFERED=1
30 ENV PYTHONDONTWRITEBYTECODE=1
31 ENV PYTHONPATH=/gunicorn-src
32 ENV GUNICORN_BIND=0.0.0.0:8000
33 ENV GUNICORN_WORKERS=4
34 ENV DIRTY_WORKERS=9
35 ENV DIRTY_TIMEOUT=300
36 ENV LOG_LEVEL=info
37
38 # Expose port
39 EXPOSE 8000
40
41 # Health check
42 HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
43 CMD curl -f http://localhost:8000/health || exit 1
44
45 # Run gunicorn with dirty arbiters
46 CMD ["gunicorn", "-c", "gunicorn_conf.py", "app:app"]