version: "3.8"

services:

  selenoid:
    image: aerokube/selenoid:latest-release
    command: >
      -conf config/browsers.json
      -video-output-dir video
      -log-output-dir logs
      -limit 10
      -timeout 5m
      -max-timeout 1h
      -container-network selenoid_default
    ports:
      - "4444:4444"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - selenoid_data:/opt/selenoid
    environment:
      - OVERRIDE_VIDEO_OUTPUT_DIR=/mnt/selenoid/video
    deploy:
      replicas: 0
      placement:
        constraints:
          - node.role == worker
      restart_policy:
        condition: on-failure

  ggr-ui:
    image: vimagick/ggr-ui
    ports:
      - "8888:8888"
    environment:
      - BROWSER_NAME=chrome
      - BROWSER_VERSION=91.0
      - BROWSER_REGION=1
      - BROWSER_HOSTS=tasks.selenoid
      - BROWSER_PORT=4444
      - BROWSER_COUNT=10
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      restart_policy:
        condition: on-failure

  selenoid-ui:
    image: aerokube/selenoid-ui:latest-release
    command: --selenoid-uri=http://ggr-ui:8888
    ports:
    - "8080:8080"
    depends_on:
      - ggr-ui
    deploy:
      replicas: 1
      placement:
        constraints:
          - node.role == manager
      restart_policy:
        condition: on-failure

volumes:
  selenoid_data:
    driver: local
    driver_opts:
      type: nfs
      o: "addr=10.0.0.96,nolock,soft,ro"
      device: ":/export/selenoid"

networks:
  default:
    driver: overlay
    attachable: true
