docker-compose.yaml
services:
otel-collector:
image: otel/opentelemetry-collector-contrib
volumes:
- ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml
redis:
image: redis
celery-worker:
build:
dockerfile: Dockerfile
context: .
target: celery_app
environment:
OTEL_SERVICE_NAME: "bootstrap-fastapi-worker"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"
CELERY__broker_url: "redis://redis:6379/0"
CELERY__result_backend: "redis://redis:6379/1"
working_dir: "/app/src"
volumes:
- '.:/app'
depends_on:
- redis
- otel-collector
- celery-beat
celery-beat:
build:
dockerfile: Dockerfile
context: .
target: celery_app
environment:
OTEL_SERVICE_NAME: "bootstrap-fastapi-worker"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"
CELERY__broker_url: "redis://redis:6379/0"
CELERY__result_backend: "redis://redis:6379/1"
working_dir: "/app/src"
volumes:
- '.:/app'
depends_on:
- redis
- otel-collector
command:
- opentelemetry-instrument
- celery
- -A
- celery_worker:app
- beat
- -l
- INFO
dev:
build:
dockerfile: Dockerfile
context: .
target: dev
environment:
WATCHFILES_FORCE_POLLING: true
OTEL_SERVICE_NAME: "bootstrap-fastapi-dev"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"
CELERY__broker_url: "redis://redis:6379/0"
CELERY__result_backend: "redis://redis:6379/1"
ports:
- '8000:8000'
working_dir: "/app/src"
volumes:
- '.:/app'
depends_on:
- redis
- otel-collector
command:
- opentelemetry-instrument
- uvicorn
- http_app:create_app
- --host
- 0.0.0.0
- --port
- "8000"
- --factory
# Remember to disable the reloader in order to allow otel instrumentation
- --reload
http:
build:
dockerfile: Dockerfile
context: .
target: http_app
depends_on:
- redis
- otel-collector
environment:
OTEL_SERVICE_NAME: "bootstrap-fastapi-http"
OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317"
CELERY__broker_url: "redis://redis:6379/0"
CELERY__result_backend: "redis://redis:6379/1"
ports:
- '8001:8000'
volumes:
- './sqlite.db:/app/sqlite.db'
# Starting from here there are only single-run commands, we can use `make` here
test:
build:
dockerfile: Dockerfile
context: .
target: dev
volumes:
- '.:/app'
command:
- "make"
- "test"
ci-test:
build:
dockerfile: Dockerfile
context: .
target: dev
command:
- "make"
- "ci-test"