version: '3'
networks:
  tango-net:
    name: tango-net
    driver: bridge

services:
  tango-db:
    image: artefact.skao.int/ska-tango-images-tango-db:10.4.19
    platform: linux/x86_64
    networks:
      - tango-net
    ports:
      - "9999:3306"
    environment:
      - MARIADB_ROOT_PASSWORD=root
      - MARIADB_DATABASE=tango
      - MARIADB_USER=tango
      - MARIADB_PASSWORD=tango

  tango-dbds:
    image: artefact.skao.int/ska-tango-images-tango-cpp:9.4.1
    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
    links:
      - "tango-db:localhost"
    depends_on:
      - tango-db
    # The proper way to wait for a service to be ready is to use a container health-check. 
    # However, this is not yet available in the container image. So an alternative approach
    # is to wait for port to be open:
    entrypoint:
      - /usr/local/bin/wait-for-it.sh
      - tango-db:3306 --timeout=30 --strict
      - --
      - /usr/local/bin/DataBaseds 2 -ORBendPoint giop:tcp:0.0.0.0:10000

  tango-rest:
    image: artefact.skao.int/ska-tango-images-tango-rest:1.14.8
    platform: linux/x86_64
    networks:
      - tango-net
    ports:
      - "8080:8080"
    environment:
      - TANGO_HOST=tango-dbds:10000
    links:
      - "tango-dbds:localhost"
    depends_on:
      - tango-dbds
    entrypoint:
      - /usr/local/bin/wait-for-it.sh
      - tango-dbds:10000 --timeout=30 --strict
      - --
      - /usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf

  tango-test:
    image: artefact.skao.int/ska-tango-images-tango-test:3.0.5
    platform: linux/x86_64
    networks:
      - tango-net
    environment:
      - TANGO_HOST=tango-dbds:10000
    links:
      - "tango-dbds:localhost"
    depends_on:
      - tango-dbds
    entrypoint:
      - /usr/local/bin/wait-for-it.sh
      - tango-dbds:10000 --timeout=30 --strict
      - --
      - /usr/local/bin/TangoTest test
