

services:
  mongodb:
    image: mongo:bionic
    expose:
      - 27017
    restart: always
    command: ["--bind_ip_all", "--replSet", "adaptor-repl"]
    volumes:
      - mongo_db_data:/data/db
    # See also: https://www.upsync.dev/2021/02/02/run-mongo-replica-set.html
    healthcheck:
      test: test $$(echo "rs.initiate({_id:'adaptor-repl',members:[{_id:0,host:\"mongodb:27017\"}]}).ok || rs.status().ok" | mongo --port 27017 --quiet) -eq 1
      interval: 10s
      start_period: 30s

  adaptor_server:
    image: registry.gitlab.com/machina_ex/adaptor_ex/adaptor_ex_server
    # build: ./ # use this to build local git tree
    restart: always
    ports:
      - 8081:8081
    depends_on:
      - mongodb
    tty: true
    stdin_open: true
    #entrypoint: [ "node", "index.js", "--headless"] # use this if you don't need mongodb
    entrypoint:
      [
        "node",
        "index.js",
        "--headless",
        "-d",
        "mongodb",
        "-m",
        "mongodb://mongodb:27017/?replicaSet=adaptor-repl"
      ]
    volumes:
      - ./adaptor_data:/usr/src/app/adaptorex

  adaptor_client:
    image: registry.gitlab.com/machina_ex/adaptor_ex/adaptor_ex_client
    restart: always
    volumes:
      - ./adaptor_client_config.json:/public/config.json
    ports:
      - 8080:80

volumes:
  mongo_db_data:
