services:
  clickhouse:
    build:
      context: ..
      dockerfile: docker/clickhouse/Dockerfile
    container_name: psch-clickhouse
    ports:
      - "19000:9000"   # Native protocol
      - "18123:8123"   # HTTP interface
    healthcheck:
      # Require the migrated schema: the init-time temp server answers SELECT 1
      # before 10-goose.sh creates events_raw.
      test: ["CMD", "clickhouse-client", "-q", "SELECT 1 FROM pg_stat_ch.events_raw LIMIT 0"]
      interval: 2s
      timeout: 5s
      retries: 10
    environment:
      CLICKHOUSE_DB: pg_stat_ch
      CLICKHOUSE_USER: default
      CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
