x-service-base: &service-base
  user: ${UID:?UID missing}:${GID:?GID missing}
  tty: true

x-volume-app: &volume-app ./:/app/

x-env-base: &env-base
  TZ: ${TZ:?TZ missing}


services:
  server:
    <<: *service-base
    image: oven/bun:1.3.4@sha256:7608db4aeb44f1fe8169cc8ec7055376b3013557b106407ccf092b00e426407d
    volumes:
      - *volume-app
    working_dir: /app/packages/server
    env_file: .env
    environment:
      <<: *env-base
    entrypoint: ["bun", "dev:bun"]

  cli:
    <<: *service-base
    image: oven/bun:1.3.4@sha256:7608db4aeb44f1fe8169cc8ec7055376b3013557b106407ccf092b00e426407d
    volumes:
      - *volume-app
    working_dir: /app
    env_file: .env
    environment:
      <<: *env-base
      NODE_ENV: development
    entrypoint: ["/bin/bash"]
    stop_signal: SIGKILL

  webapp:
    <<: *service-base
    image: node:22.21.1@sha256:4ad2c2b350ab49fb637ab40a269ffe207c61818bb7eb3a4ea122001a0c605e1f
    ports:
      - ${PORT:?PORT missing}:80
    volumes:
      - *volume-app
    working_dir: /app/packages/webapp
    environment:
      <<: *env-base
    entrypoint: ["npm", "run", "dev"]
    stop_signal: SIGKILL

  tempo:
    <<: *service-base
    image: grafana/tempo:latest@sha256:cfe9b6a2e9730f3acb4437727a25e481554a7e00685c6170af73ac52c46c9707
    command: [-config.file=/etc/tempo.yaml]
    volumes:
      - ./telemetry/tempo.yaml:/etc/tempo.yaml
      - ./tempo_data/:/data/
    stop_signal: SIGKILL

  prometheus:
    image: prom/prometheus:v3.8.0@sha256:d936808bdea528155c0154a922cd42fd75716b8bb7ba302641350f9f3eaeba09
    command:
      - --config.file=/etc/prometheus.yaml
      - --web.enable-remote-write-receiver
      - --enable-feature=exemplar-storage
    volumes:
      - ./telemetry/prometheus.yaml:/etc/prometheus.yaml

  grafana:
    image: grafana/grafana:latest@sha256:793c8719b0043ed885d1e75200a62d8adf63f0eae00f6f12b7a98eb7293a525c
    volumes:
      - ./telemetry/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
    environment:
      GF_AUTH_ANONYMOUS_ENABLED: true
      GF_AUTH_ANONYMOUS_ORG_ROLE: Admin
      GF_AUTH_DISABLE_LOGIN_FORM: true
      GF_FEATURE_TOGGLES_ENABLE: traceqlEditor
