services:
  mongodb:
    command:
      - '--replSet'
      - rs0
      - '--bind_ip_all'
      - '--keyFile'
      - /etc/security.keyFile
    container_name: rocketchat-mongodb
    environment:
      MONGO_INITDB_ROOT_PASSWORD: ADMIN_PASSWORD
      MONGO_INITDB_ROOT_USERNAME: root
    expose:
      - 27017
    image: mongo:7.0
    restart: unless-stopped
    volumes:
      - data:/data/db
      - security.keyFile:/etc/security.keyFile:ro
  rocketchat:
    command: |
      sh -c "
        echo 'Waiting 20s for MongoDB...'
        sleep 20
         exec node main.js
      "
    container_name: rocketchat
    depends_on:
      - mongodb
    environment:
      DEPLOY_METHOD: docker
      DEPLOY_PLATFORM: compose
      MONGO_OPLOG_URL: >-
        mongodb://root:ADMIN_PASSWORD@rocketchat-mongodb:27017/local?replicaSet=rs0&authSource=admin
      MONGO_URL: >-
        mongodb://root:ADMIN_PASSWORD@rocketchat-mongodb:27017/rocketchat?replicaSet=rs0&authSource=admin
      PORT: 3000
      ROOT_URL: http://IP_YOU_ACCESS_ROCKET_CHAT_FROM:PORT_FOR_ACCESS
    expose:
      - 3000
    image: registry.rocket.chat/rocketchat/rocket.chat:8.1.1
    ports:
      - 'PORT_FOR_ACCESS:3000'
    restart: unless-stopped
    volumes:
      - uploads:/app/uploads
volumes:
  mongo_data: Null
