Skip to content

Commit 626b4df

Browse files
committed
Replace celery with dramatiq in docker
Signed-off-by: Federico Busetti <[email protected]>
1 parent cd9afbf commit 626b4df

File tree

2 files changed

+21
-36
lines changed

2 files changed

+21
-36
lines changed

Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ RUN make dev-dependencies
5151
# when signals are propagated, we disable it in dev image default CMD
5252
CMD ["uvicorn", "http_app:create_app", "--host", "0.0.0.0", "--port", "8000", "--factory", "--reload"]
5353

54-
# Installs requirements to run production celery application
55-
FROM base_builder AS celery_builder
54+
# Installs requirements to run production dramatiq application
55+
FROM base_builder AS dramatiq_builder
5656
RUN poetry install --no-root
5757

5858
# Installs requirements to run production http application
@@ -79,9 +79,10 @@ COPY --chown=nonroot:nonroot src/http_app ./http_app
7979
# Run CMD using array syntax, so it's uses `exec` and runs as PID1
8080
CMD ["opentelemetry-instrument", "uvicorn", "http_app:create_app", "--host", "0.0.0.0", "--port", "8000", "--factory"]
8181

82-
# Copy the celery python package and requirements from relevant builder
83-
FROM base_app AS celery_app
84-
COPY --from=celery_builder /poetryvenvs /poetryvenvs
85-
COPY --chown=nonroot:nonroot src/celery_worker ./celery_worker
82+
# Copy the dramatiq python package and requirements from relevant builder
83+
FROM base_app AS dramatiq_app
84+
COPY --from=dramatiq_builder /poetryvenvs /poetryvenvs
85+
COPY --chown=nonroot:nonroot src/dramatiq_worker ./dramatiq_worker
8686
# Run CMD using array syntax, so it's uses `exec` and runs as PID1
87-
CMD ["opentelemetry-instrument", "celery", "-A", "celery_worker:app", "worker", "-l", "INFO"]
87+
# TODO: Review processes/threads
88+
CMD ["opentelemetry-instrument", "dramatiq", "-p", "1", "-t", "1", "dramatiq_worker"]

docker-compose.yaml

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,16 @@ services:
88
redis:
99
image: redis
1010

11-
celery-worker:
11+
dramatiq:
1212
build:
1313
dockerfile: Dockerfile
1414
context: .
15-
target: celery_app
15+
target: dramatiq_app
1616
environment:
17-
OTEL_SERVICE_NAME: "bootstrap-fastapi-worker"
18-
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"
19-
CELERY__broker_url: "redis://redis:6379/0"
20-
CELERY__result_backend: "redis://redis:6379/1"
21-
working_dir: "/app/src"
22-
volumes:
23-
- '.:/app'
24-
depends_on:
25-
- redis
26-
- otel-collector
27-
- celery-beat
28-
29-
celery-beat:
30-
build:
31-
dockerfile: Dockerfile
32-
context: .
33-
target: celery_app
34-
environment:
35-
OTEL_SERVICE_NAME: "bootstrap-fastapi-worker"
17+
WATCHFILES_FORCE_POLLING: true
18+
OTEL_SERVICE_NAME: "bootstrap-fastapi-dramatiq-worker"
3619
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"
37-
CELERY__broker_url: "redis://redis:6379/0"
38-
CELERY__result_backend: "redis://redis:6379/1"
20+
DRAMATIQ__REDIS_URL: "redis://redis:6379/0"
3921
working_dir: "/app/src"
4022
volumes:
4123
- '.:/app'
@@ -44,12 +26,14 @@ services:
4426
- otel-collector
4527
command:
4628
- opentelemetry-instrument
47-
- celery
48-
- -A
49-
- celery_worker:app
50-
- beat
51-
- -l
52-
- INFO
29+
- dramatiq
30+
- --watch
31+
- .
32+
- -p
33+
- "1"
34+
- -t
35+
- "1"
36+
- dramatiq_worker
5337

5438
dev:
5539
build:

0 commit comments

Comments
 (0)