version: '3.3'

services:
  artix-bi-api:
    restart: always
    image: dockerregistry.artix.su:2443/artix-bi-api:latest
    container_name: artix-metabase
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /etc/localtime:/etc/localtime:ro
      - ./licence-bi:/opt/loyalty-bi/licence/
    environment:
      metabase.host: metabase
      postgresql_db: postgresql
      clickhouse_db: clickhouse
      contragent_id: 'PUT_YOUR_CONTRAGENT_TOKEN_HERE'
    ports:
      - "9099:9099"
    depends_on:
      - metabase
    networks:
      - metabase_network

  metabase:
    restart: always
    image: dockerregistry.artix.su:2443/artix-metabase:v0.50.28
    depends_on:
      - postgresql
    container_name: metabase
    ports:
      - 3000:3000
    environment:
      MB_DB_TYPE: "postgres"
      MB_DB_DBNAME: "metabasedb"
      MB_DB_PORT: "5432"
      MB_DB_USER: "netroot"
      MB_DB_PASS: "netroot"
      MB_DB_HOST: postgresql
    networks:
      - metabase_network

  postgresql:
    restart: always
    image: dockerregistry.artix.su:2443/postgres:15.2-local
    environment:
      POSTGRES_USER: "netroot"
      POSTGRES_PASSWORD: "netroot"
      POSTGRES_MULTIPLE_DATABASES: metabasedb,artix_bi
    volumes:
      - postgres-data:/var/lib/postgresql/data
      - ./create-multiple-postgresql-databases.sh:/docker-entrypoint-initdb.d/init.sh
    ports:
      - 5432:5432
    networks:
      - metabase_network

  clickhouse:
    restart: always
    image: clickhouse/clickhouse-server:24.8.4
    container_name: clickhouse
    environment:
      CLICKHOUSE_USER: netroot
      CLICKHOUSE_PASSWORD: netroot
    volumes:
      - ./conf/users.xml:/etc/clickhouse-server/users.xml
      - ./data/clickhouse:/var/lib/clickhouse
      - ./conf/dictionary_settings.xml:/etc/clickhouse-server/conf.d/dictionary_settings.xml
      - ./dictionaries/currency_name_dictionary.xml:/opt/dictionaries/currency_name_dictionary.xml
      - ./dictionaries/region.csv:/var/lib/clickhouse/user_files/region.csv
    ports:
      - 8123:8123
      - 9001:9001
    networks:
      - metabase_network
      - clickhouse


networks:
  metabase_network:
  clickhouse:

volumes:
  postgres-data:
