Compose file of the emulation stack
networks:
  mobile_2g:
    attachable: true
    driver: overlay
    labels:
      org.fundacionctic.wotemu.net: ''
    name: mobile_2g
  wifi:
    attachable: true
    driver: overlay
    labels:
      org.fundacionctic.wotemu.net: ''
    name: wifi
services:
  broker:
    command:
    - broker
    depends_on:
    - gw_mobile_2g
    - docker_api_proxy
    - redis
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.broker: ''
    networks:
    - mobile_2g
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  clock_http:
    command:
    - app
    - --path
    - wotemu_clock
    - --enable-http
    depends_on:
    - docker_api_proxy
    - gw_wifi
    - redis
    deploy:
      replicas: 2
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.node: ''
    networks:
    - wifi
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  clock_mqtt:
    command:
    - app
    - --path
    - wotemu_clock
    - --enable-mqtt
    depends_on:
    - gw_mobile_2g
    - docker_api_proxy
    - gw_wifi
    - redis
    deploy:
      replicas: 2
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      MQTT_BROKER_HOST: broker.mobile_2g
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.node: ''
    networks:
    - mobile_2g
    - wifi
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  clock_property_reader:
    command:
    - app
    - --path
    - wotemu_reader
    - --func-param
    - servient_host
    - clock_http.wifi
    - --func-param
    - thing_id
    - urn:org:fundacionctic:thing:clock
    depends_on:
    - docker_api_proxy
    - gw_wifi
    - redis
    deploy:
      replicas: 2
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.node: ''
    networks:
    - wifi
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  clock_sub_http:
    command:
    - app
    - --path
    - wotemu_subscriber
    - --func-param
    - servient_host
    - clock_http.wifi
    - --func-param
    - thing_id
    - urn:org:fundacionctic:thing:clock
    depends_on:
    - docker_api_proxy
    - gw_wifi
    - redis
    deploy:
      replicas: 4
      resources:
        limits:
          memory: 200M
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
      TARGET_CPU_SPEED: 200
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.node: ''
    networks:
    - wifi
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  clock_sub_mqtt:
    command:
    - app
    - --path
    - wotemu_subscriber
    - --func-param
    - servient_host
    - clock_mqtt.wifi
    - --func-param
    - thing_id
    - urn:org:fundacionctic:thing:clock
    depends_on:
    - gw_mobile_2g
    - docker_api_proxy
    - gw_wifi
    - redis
    deploy:
      replicas: 2
      resources:
        limits:
          memory: 200M
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
      TARGET_CPU_SPEED: 200
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.node: ''
    networks:
    - mobile_2g
    - wifi
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  docker_api_proxy:
    deploy:
      placement:
        constraints:
        - node.role == manager
    environment:
      CONTAINERS: '1'
      NETWORKS: '1'
      NODES: '1'
      PATCH_PRIVILEGED: '1'
      SERVICES: '1'
      TASKS: '1'
    image: tecnativa/docker-socket-proxy
    networks:
    - mobile_2g
    - wifi
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  error:
    command:
    - app
    - --path
    - wotemu_error
    depends_on:
    - docker_api_proxy
    - gw_wifi
    - redis
    deploy:
      replicas: 2
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.node: ''
    networks:
    - wifi
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  gw_mobile_2g:
    command:
    - gateway
    - delay --time 700 --jitter 100 --distribution normal
    - rate --rate 100kbit
    depends_on:
    - docker_api_proxy
    - redis
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.gw: ''
    networks:
    - mobile_2g
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  gw_wifi:
    command:
    - gateway
    - delay --time 25 --jitter 5 --distribution normal
    - rate --rate 50mbit
    depends_on:
    - docker_api_proxy
    - redis
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.gw: ''
    networks:
    - wifi
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  redis:
    image: redis:5
    labels:
      org.fundacionctic.wotemu.redis: ''
    networks:
    - mobile_2g
    - wifi
    ports:
    - '6379'
  worker:
    command:
    - app
    - --path
    - wotemu_worker
    - --enable-ws
    depends_on:
    - gw_mobile_2g
    - docker_api_proxy
    - redis
    deploy:
      replicas: 1
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.node: ''
    networks:
    - mobile_2g
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
  worker_caller:
    command:
    - app
    - --path
    - wotemu_caller
    - --func-param
    - servient_host
    - worker.mobile_2g
    - --func-param
    - thing_id
    - urn:org:fundacionctic:thing:worker
    depends_on:
    - gw_mobile_2g
    - docker_api_proxy
    - redis
    deploy:
      replicas: 2
    environment:
      DOCKER_PROXY_URL: tcp://docker_api_proxy:2375/
      NODE_HOSTNAME: '{{.Node.Hostname}}'
      NODE_ID: '{{.Node.ID}}'
      PATCH_PRIVILEGED: '1'
      PORT_CATALOGUE: '9090'
      PORT_COAP: '5683'
      PORT_HTTP: '80'
      PORT_MQTT: '1883'
      PORT_WS: '81'
      REDIS_URL: redis://redis
      SERVICE_ID: '{{.Service.ID}}'
      SERVICE_NAME: '{{.Service.Name}}'
    hostname: '{{.Task.Name}}'
    image: wotemu
    labels:
      org.fundacionctic.wotemu.node: ''
    networks:
    - mobile_2g
    privileged: true
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
version: '3.7'