chore(compose): add shared json-file logging config and component labels
All checks were successful
CVE Scan & Docker Build / security-scan (push) Successful in 52s
CVE Scan & Docker Build / build-and-push (push) Successful in 3m21s

Introduce x-logging anchor with json-file driver, size/file caps, and
container name tagging so Alloy on puck can reliably tail every service
through the Docker socket. Apply to all services and inject
MNEMOSYNE_COMPONENT env vars (init/app/mcp/worker) for consistent log
attribution both
This commit is contained in:
2026-05-11 13:52:00 -04:00
parent 8ddbcf4612
commit 551c641e90
5 changed files with 225 additions and 37 deletions

View File

@@ -47,6 +47,20 @@
# and is the typical re-run target after embedding-model changes).
# =============================================================================
# -----------------------------------------------------------------------------
# Shared logging config — JSON to stdout, picked up by Alloy via the Docker
# socket on the host and shipped to Loki. Pinning json-file (Docker's default)
# so Alloy's discovery.docker + loki.source.docker on puck sees a consistent
# driver across every service, and bounding log retention per container so a
# misbehaving service can't fill the disk between Alloy tails.
# -----------------------------------------------------------------------------
x-logging: &default-logging
driver: json-file
options:
tag: "{{.Name}}"
max-size: "10m"
max-file: "5"
services:
# ── Static-file seeder: copies /app/staticfiles into the shared volume on
@@ -60,6 +74,7 @@ services:
volumes:
- mnemosyne-static:/shared-static
restart: "no"
logging: *default-logging
# ── Init sidecar: one-shot Postgres migrate + library-type seed. Runs on
# every `up` and exits. Long-running services below depend on
@@ -92,10 +107,16 @@ services:
- DB_PORT=${DB_PORT}
# Neo4j (load_library_types writes Library defaults into the graph)
- NEOMODEL_NEO4J_BOLT_URL=${NEOMODEL_NEO4J_BOLT_URL}
# Logging
# Logging (MNEMOSYNE_COMPONENT is injected by settings.py into every
# log line as a static JSON field; Alloy on puck reads the compose
# service name directly off the Docker label and uses that as the
# Loki `component` label, but we still set it here so operators
# tail-ing ``docker logs`` see the same attribution)
- MNEMOSYNE_COMPONENT=init
- LOGGING_LEVEL=${LOGGING_LEVEL}
- DJANGO_LOGGING_LEVEL=${DJANGO_LOGGING_LEVEL}
restart: "no"
logging: *default-logging
# ── App: Django REST API + admin ──────────────────────────────────────────
@@ -154,9 +175,11 @@ services:
- RERANKER_MAX_CANDIDATES=${RERANKER_MAX_CANDIDATES}
- RERANKER_TIMEOUT=${RERANKER_TIMEOUT}
# Logging
- MNEMOSYNE_COMPONENT=app
- LOGGING_LEVEL=${LOGGING_LEVEL}
- DJANGO_LOGGING_LEVEL=${DJANGO_LOGGING_LEVEL}
restart: unless-stopped
logging: *default-logging
depends_on:
static-init:
condition: service_completed_successfully
@@ -228,9 +251,11 @@ services:
- RERANKER_MAX_CANDIDATES=${RERANKER_MAX_CANDIDATES}
- RERANKER_TIMEOUT=${RERANKER_TIMEOUT}
# Logging
- MNEMOSYNE_COMPONENT=mcp
- LOGGING_LEVEL=${LOGGING_LEVEL}
- DJANGO_LOGGING_LEVEL=${DJANGO_LOGGING_LEVEL}
restart: unless-stopped
logging: *default-logging
depends_on:
init:
condition: service_completed_successfully
@@ -303,9 +328,11 @@ services:
- EMBEDDING_BATCH_SIZE=${EMBEDDING_BATCH_SIZE}
- EMBEDDING_TIMEOUT=${EMBEDDING_TIMEOUT}
# Logging
- MNEMOSYNE_COMPONENT=worker
- LOGGING_LEVEL=${LOGGING_LEVEL}
- CELERY_LOGGING_LEVEL=${CELERY_LOGGING_LEVEL}
restart: unless-stopped
logging: *default-logging
depends_on:
app:
condition: service_healthy
@@ -324,6 +351,7 @@ services:
web:
image: nginx:alpine
restart: unless-stopped
logging: *default-logging
depends_on:
app:
condition: service_healthy