trails/docker-compose.dev.yml
Ullrich Schäfer e60c9d7057 refactor(infra): mount config dirs not single files; reload on deploy
Single-file bind mounts (./foo.yml:/etc/foo.yml) pin to the host file's
inode at container-create time. The CD pipeline scp's a replacement file
(new inode), so the running container keeps reading the OLD inode —
`docker compose up -d` won't recreate on a content-only change, and
neither restart/SIGHUP/`caddy reload` re-reads the new file. Net effect:
config-only infra PRs deployed "successfully" but never took effect
(confirmed with PR #500's prometheus.yml; the WAL retention work only
applied because #498 also changed docker-compose.yml, forcing a
recreate). Caddyfile changes had the same latent gap.

Switch the four single-file config mounts to DIRECTORY mounts, which
resolve children live so a reload/restart picks up the new file:

- prometheus, loki, promtail: mount ./<svc> dir (loki/promtail
  --config.file paths updated to the real filenames).
- caddy: move Caddyfile into caddy/ and mount the dir; ./sites overlays
  /etc/caddy/sites (caddy/sites/.gitkeep keeps the mountpoint). Container
  path /etc/caddy/Caddyfile is unchanged, so every `caddy reload --config
  /etc/caddy/Caddyfile` ref still works. scp source paths in cd-infra and
  cd-apps updated to ship the caddy/ dir.

cd-infra now applies config-only changes after `up -d`: SIGHUP prometheus
(zero downtime), restart loki+promtail (no SIGHUP reload), caddy reload
(graceful). Mirrored prometheus/loki mounts in docker-compose.dev.yml.

Validated: docker compose config (both files), caddy validate from the
new path, read-only-parent + sites-overlay mount mechanics, workflow YAML.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 13:10:35 +02:00

75 lines
2.1 KiB
YAML

services:
postgres:
image: imresamu/postgis:16-3.4 # multi-arch (amd64 + arm64)
ports:
- "5432:5432"
environment:
POSTGRES_USER: trails
POSTGRES_PASSWORD: trails
POSTGRES_DB: trails
command: ["postgres", "-c", "shared_preload_libraries=pg_stat_statements"]
volumes:
- pgdata:/var/lib/postgresql/data
- ./infrastructure/postgres/init-grafana-user.sql:/docker-entrypoint-initdb.d/init-grafana-user.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U trails"]
interval: 5s
timeout: 5s
retries: 5
brouter:
build: docker/brouter
ports:
- "17777:17777"
volumes:
- brouter_segments:/data/segments
healthcheck:
test: ["CMD-SHELL", "curl -s http://localhost:17777/ > /dev/null 2>&1"]
interval: 5s
timeout: 5s
retries: 30
start_period: 10s
prometheus:
image: prom/prometheus:latest
profiles: [monitoring]
ports:
- "9090:9090"
volumes:
# Directory mount (not the file) to match prod — a single-file bind
# mount pins the host inode, so a replaced config is never seen.
- ./infrastructure/prometheus:/etc/prometheus:ro
- prometheus_data:/prometheus
grafana:
image: grafana/grafana:latest
profiles: [monitoring]
ports:
- "3002:3000"
environment:
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
GF_AUTH_DISABLE_LOGIN_FORM: "true"
volumes:
- ./infrastructure/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
- ./infrastructure/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
- ./infrastructure/grafana/dashboards:/var/lib/grafana/dashboards:ro
- grafana_data:/var/lib/grafana
loki:
image: grafana/loki:latest
profiles: [monitoring]
ports:
- "3100:3100"
volumes:
# Directory mount (not the file) to match prod.
- ./infrastructure/loki:/etc/loki:ro
- loki_data:/loki
command: ["-config.file=/etc/loki/loki-config.yml"]
volumes:
pgdata:
brouter_segments:
prometheus_data:
grafana_data:
loki_data: