version: '3.5'

services:
  integration:
    container_name: integration-tests
    image: smartcontract/integration
    build:
      context: ../../
      dockerfile: tools/docker/integration.Dockerfile
      args:
        - SRCROOT
    volumes:
      # Forwards the local Docker socket to the container.
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - node
      - echo-server
      - cypress-job-server
    environment:
      - SRCROOT
      - GETH_MODE
      - ADAMORACLE_DEV=TRUE # need this for service agreements subcommand
      - ADAMORACLE_URL
      - ETH_HTTP_URL
      - ECHO_SERVER_URL
      - EXTERNAL_ADAPTER_URL
      - CLIENT_NODE_URL # used to send remote commands
      - CYPRESS_JOB_SERVER_PORT
      - CYPRESS_JOB_SERVER_HOST
      - CYPRESS_EXPLORER_URL
      - CYPRESS_ADAMORACLE_URL=$ADAMORACLE_URL
    secrets:
      - apicredentials

  echo-server:
    container_name: echo-server
    image: smartcontract/echo-server
    build:
      context: ../../
      dockerfile: tools/echo-server/Dockerfile
      args:
        - SRCROOT
    environment:
      - PORT=$ECHO_SERVER_PORT

  cypress-job-server:
    container_name: cypress-job-server
    image: smartcontract/cypress-job-server
    build:
      context: ../../
      dockerfile: tools/cypress-job-server/Dockerfile
      args:
        - SRCROOT
    command: '{\"last\":\ \"3843.95\"}'
    ports:
      - '6692:6692'
    environment:
      - JOB_SERVER_PORT=$CYPRESS_JOB_SERVER_PORT

  external-adapter:
    container_name: external-adapter
    image: smartcontract/external-adapter
    build:
      context: ../../
      dockerfile: tools/external-adapter/Dockerfile
    ports:
      - '6644:6644'
    environment:
      - EXTERNAL_ADAPTER_PORT=$EXTERNAL_ADAPTER_PORT

  node:
    entrypoint: ''
    command: /bin/sh -c "adamoracle node import /run/secrets/keystore && adamoracle node start -d -p /run/secrets/node_password -a /run/secrets/apicredentials"
    depends_on:
      - explorer
    environment:
      ALLOW_ORIGINS: http://localhost:3000,http://localhost:6688,http://integration:3000,http://integration:6688,http://node:3000,http://node:6688
