# Compose with x- extension fields and YAML anchors. Both are load-bearing here: `x-` keys are
# ignored by Compose but are ordinary YAML, and the anchors under them are merged into services
# by the YAML loader before Compose ever sees the document. A tool that strips x- keys BEFORE
# parsing YAML destroys the anchors and the file stops resolving.
x-logging: &default-logging
  driver: json-file
  options:
    max-size: 10m
    max-file: "3"

x-common: &common
  restart: unless-stopped
  logging: *default-logging
  networks:
    - backend
  environment:
    TZ: Etc/UTC

x-healthcheck-defaults: &healthcheck-defaults
  interval: 10s
  timeout: 2s
  retries: 3

services:
  api:
    <<: *common
    image: registry.example.invalid/example-org/orders:1.4.0
    ports:
      - "8080:8080"
    healthcheck:
      <<: *healthcheck-defaults
      test: ["CMD", "example-healthcheck"]

  worker:
    <<: *common
    image: registry.example.invalid/example-org/worker:1.4.0
    command: ["worker", "--queue", "orders"]
    healthcheck:
      <<: *healthcheck-defaults
      retries: 10

networks:
  backend:
    driver: bridge
