Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

3.5 KB
Raw Blame
# Compose stack for the API integration test suite (`pnpm test:api`).
#
# This is NOT the deployable stack — see docker-compose.yml for that. Databases
# run on tmpfs and are discarded on `down`, so every run starts from an empty
# schema (migrations + the default admin user are applied by the umami image on
# boot via scripts/start-docker.sh).
#
# Profiles:
#   postgres    umami + Postgres              -> pnpm test:api
#   clickhouse  umami + Postgres + ClickHouse -> pnpm test:api:clickhouse
#
# Environment overrides:
#   UMAMI_TEST_PORT   host port for the app (default 3100, avoids the dev server on 3000)
#   UMAMI_TEST_IMAGE  image tag to run/build (default umami-test:local)
#   SKIP_BUILD_GEO    "1" (default) skips the MaxMind download during the image build

x-umami-service: &umami-service
  image: ${UMAMI_TEST_IMAGE:-umami-test:local}
  build:
    context: .
    args:
      SKIP_BUILD_GEO: ${SKIP_BUILD_GEO:-1}
  ports:
    - "${UMAMI_TEST_PORT:-3100}:3000"
  init: true
  healthcheck:
    test: ["CMD-SHELL", "curl -fsS http://localhost:3000/api/heartbeat || exit 1"]
    interval: 2s
    timeout: 5s
    retries: 90
    start_period: 20s

x-umami-env: &umami-env
  DATABASE_URL: postgresql://umami:umami@db:5432/umami
  APP_SECRET: umami-api-test-secret
  TWO_FACTOR_ENCRYPTION_KEY: 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
  # Playwright/curl user agents are classified as bots; without this /api/send silently drops events.
  DISABLE_BOT_CHECK: "1"
  DISABLE_TELEMETRY: "1"
  DISABLE_UPDATES: "1"
  MCP_ENABLED: "1"

services:
  db:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: umami
      POSTGRES_USER: umami
      POSTGRES_PASSWORD: umami
    tmpfs:
      - /var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U umami -d umami"]
      interval: 2s
      timeout: 5s
      retries: 30

  umami:
    <<: *umami-service
    profiles: [postgres]
    environment: *umami-env
    depends_on:
      db:
        condition: service_healthy

  clickhouse:
    # Pinned to an LTS release. 26.7+ rejects db/clickhouse/schema.sql because
    # website_event_stats_hourly has dimension columns outside the sorting key
    # (see allow_dimensions_outside_sorting_key).
    image: clickhouse/clickhouse-server:25.8
    profiles: [clickhouse]
    environment:
      CLICKHOUSE_DB: umami
      CLICKHOUSE_USER: umami
      CLICKHOUSE_PASSWORD: umami
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    tmpfs:
      - /var/lib/clickhouse
    volumes:
      # The image runs /docker-entrypoint-initdb.d/*.sql on first start (empty data dir).
      - ./tests/api/docker/clickhouse-init/00-create-db.sql:/docker-entrypoint-initdb.d/00-create-db.sql:ro
      - ./db/clickhouse/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql:ro
    healthcheck:
      # Healthy only once schema.sql has been applied (session_link is the last table it creates).
      test:
        [
          "CMD-SHELL",
          "clickhouse-client --user umami --password umami --query \"SELECT throwIf(count() = 0) FROM system.tables WHERE database = 'umami' AND name = 'session_link'\"",
        ]
      interval: 2s
      timeout: 5s
      retries: 90
      start_period: 10s

  umami-clickhouse:
    <<: *umami-service
    profiles: [clickhouse]
    environment:
      <<: *umami-env
      CLICKHOUSE_URL: http://umami:umami@clickhouse:8123/umami
    depends_on:
      db:
        condition: service_healthy
      clickhouse:
        condition: service_healthy