networks:
  tango-net:
    name: tango-net
    driver: bridge

services:
  tango-db:
    image: artefact.skao.int/ska-tango-images-tango-db:11.2.6
    platform: linux/x86_64
    networks:
      - tango-net
    environment:
      - MARIADB_ROOT_PASSWORD=root
      - MARIADB_DATABASE=tango
      - MARIADB_USER=tango
      - MARIADB_PASSWORD=tango
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect"]
      start_period: 10s
      interval: 500ms
      timeout: 1s
      retries: 3

  tango-dbds:
    image: artefact.skao.int/ska-tango-images-tango-databaseds:5.23.3
    platform: linux/x86_64
    networks:
      - tango-net
    ports:
      - "10000:10000"
    environment:
      - TANGO_HOST=localhost:10000
      - MYSQL_HOST=tango-db:3306
      - MYSQL_USER=tango
      - MYSQL_PASSWORD=tango
      - MYSQL_DATABASE=tango
    depends_on:
      tango-db:
        condition: service_healthy
    entrypoint: Databaseds
    command:
      - "2"
      - -ORBendPoint
      - giop:tcp::10000
    healthcheck:
      test: ["CMD", "sh", "-c", "/usr/local/bin/tango_admin --ping-database || exit 1"]
      start_period: 10s
      start_interval: 500ms
      timeout: 3s
      retries: 3

  load-tango-config:
    image: artefact.skao.int/ska-tango-images-tango-admin:1.27.0
    platform: linux/x86_64
    networks:
      - tango-net
    environment:
      - TANGO_HOST=tango-dbds:10000
    depends_on:
      tango-dbds:
        condition: service_healthy
    command:
     - "--add-server"
     - "TangoTest/my_instance"
     - "TangoTest"
     - "sys/tg_test/2"
     
  load-test-server:
    image: artefact.skao.int/ska-tango-images-tango-admin:1.27.0
    platform: linux/x86_64
    networks:
      - tango-net
    environment:
      - TANGO_HOST=tango-dbds:10000
    depends_on:
      tango-dbds:
        condition: service_healthy
    command:
     - "--add-server"
     - "MyDevice/test"
     - "MyDevice"
     - "test/my_device/1,test/my_device/2,test/my_device/3"
     
  tango-test:
    image: artefact.skao.int/ska-tango-images-tango-test:3.10.3
    platform: linux/x86_64
    networks:
      - tango-net
    environment:
      - TANGO_HOST=tango-dbds:10000
    depends_on:
      tango-dbds:
        condition: service_healthy
      load-tango-config:
        condition: service_completed_successfully
    healthcheck:
      test: ["CMD", "sh", "-c", "/usr/local/bin/tango_admin --ping-device sys/tg_test/2 || exit 1"]
      start_period: 10s
      interval: 500ms
      timeout: 1s
      retries: 3
    command:
      - "my_instance"

