diff --git a/.gitignore b/.gitignore index 72f11a9b..33bc3bac 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ bot/results* bot/train_test_split/ .tensorboard* .rasa/ +*.log ### Rasa X ### events.db diff --git a/Makefile b/Makefile index 1e580ba0..bb683fc6 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ down: init: make build make train - make shell + make webchat logs: docker compose logs \ diff --git a/bot/endpoints.yml b/bot/endpoints.yml index fffae93b..1f23d59d 100644 --- a/bot/endpoints.yml +++ b/bot/endpoints.yml @@ -8,4 +8,8 @@ tracker_store: db: "bot" username: ${MONGO_USERNAME} password: ${MONGO_PASSWORD} - auth_source: "bot" \ No newline at end of file + auth_source: "bot" + +event_broker: + type: "file" + path: "rasa_events.log" \ No newline at end of file diff --git a/bot/requirements.txt b/bot/requirements.txt index 80a6c8ec..18326f15 100644 --- a/bot/requirements.txt +++ b/bot/requirements.txt @@ -1 +1 @@ -rasa==3.6.5 +rasa==3.6.6 diff --git a/docker-compose-rocket.yml b/docker-compose-rocket.yml new file mode 100644 index 00000000..8111c50f --- /dev/null +++ b/docker-compose-rocket.yml @@ -0,0 +1,112 @@ +version: "3.9" + +services: + # ================================= Bot ===================================== + # Generic Rasa bot, used to run console for example. + bot: + build: + context: . + dockerfile: ./docker/bot.Dockerfile + container_name: bot + env_file: + - ./env/bot.env + volumes: + - ./bot/:/bot/ + ports: + - 5005:5005 + depends_on: + - actions + - mongo + networks: + - bot + # ============================ Tracker Store================================= + # A mongodb container as rasa tracker store. + mongo: + container_name: mongo + image: mongo:6.0 + restart: unless-stopped + env_file: + - env/bot.env + ports: + - 27017:27017 + networks: + - bot + volumes: + - ./data/db:/data/db + + # ================================= Actions ================================= + # Rasa middleware used to connect with external APIs. + actions: + build: + context: . + dockerfile: ./docker/actions.Dockerfile + container_name: actions + env_file: + - ./env/bot.env + ports: + - 5055:5055 + volumes: + - ./bot:/bot + command: sh -c "python -m rasa_sdk --actions actions" + networks: + - bot + + # =============================== Rocket.Chat ================================= + # Rocket.Chat instance. + rocketchat: + image: registry.rocket.chat/rocketchat/rocket.chat:latest + command: > + bash -c + "for i in `seq 1 30`; do + node main.js && + s=$$? && break || s=$$?; + echo \"Tried $$i times. Waiting 5 secs...\"; + sleep 5; + done; (exit $$s)" + restart: unless-stopped + volumes: + - ./uploads:/app/uploads + environment: + - PORT=3000 + - ROOT_URL=http://localhost:3000 + - MONGO_URL=mongodb://mongo-rocket:27017/rocketchat + - MONGO_OPLOG_URL=mongodb://mongo-rocket:27017/local + #- REG_TOKEN=${REG_TOKEN} + depends_on: + - mongo-rocket + ports: + - 3000:3000 + # =============================== Mongo ================================= + # Mongo database and replica set. + mongo-rocket: + image: mongo:4.0 + restart: unless-stopped + volumes: + - ./data/db:/data/db + command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1 + + # this container's job is just run the command to initialize the replica set. + # it will run the command and remove himself (it will not stay running) + mongo-init-replica: + image: mongo:4.0 + command: > + bash -c + "for i in `seq 1 30`; do + mongo mongo/rocketchat --eval \" + rs.initiate({ + _id: 'rs0', + members: [ { _id: 0, host: 'localhost:27017' } ]})\" && + s=$$? && break || s=$$?; + echo \"Tried $$i times. Waiting 5 secs...\"; + sleep 5; + done; (exit $$s)" + depends_on: + - mongo-rocket + +volumes: + mongo_data: + rocket_uploads: + +networks: + bot: + driver: bridge diff --git a/docker-compose-telegram.yml b/docker-compose-telegram.yml new file mode 100644 index 00000000..30187c16 --- /dev/null +++ b/docker-compose-telegram.yml @@ -0,0 +1,74 @@ +version: "3.9" + +services: + # ================================= Bot ===================================== + # Generic Rasa bot, used to run console for example. + bot: + build: + context: . + dockerfile: ./docker/bot.Dockerfile + container_name: bot + env_file: + - ./env/bot.env + volumes: + - ./bot/:/bot/ + ports: + - 5005:5005 + depends_on: + - actions + - mongo + networks: + - bot + # ============================ Tracker Store================================= + # A mongodb container as rasa tracker store. + mongo: + container_name: mongo + image: mongo:6.0 + restart: unless-stopped + env_file: + - env/bot.env + ports: + - 27017:27017 + networks: + - bot + volumes: + - ./data/db:/data/db + + # ================================= Actions ================================= + # Rasa middleware used to connect with external APIs. + actions: + build: + context: . + dockerfile: ./docker/actions.Dockerfile + container_name: actions + env_file: + - ./env/bot.env + ports: + - 5055:5055 + volumes: + - ./bot:/bot + command: sh -c "python -m rasa_sdk --actions actions" + networks: + - bot + + # ============================ Telegram Bot ================================= + # Specific Rasa bot integrated with Telegram. + bot-telegram: + build: + context: . + dockerfile: ./docker/bot.Dockerfile + volumes: + - ./bot/:/bot/ + env_file: + - ./env/bot-telegram.env + - ./env/bot.env + ports: + - 5005:5005 + command: sh -c "make telegram" + +volumes: + mongo_data: + +networks: + bot: + driver: bridge diff --git a/docker-compose.yml b/docker-compose.yml index ee716dc0..e8cfd3ba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -62,90 +62,6 @@ services: networks: - bot - # ============================ Telegram Bot ================================= - # Specific Rasa bot integrated with Telegram. - bot-telegram: - build: - context: . - dockerfile: ./docker/bot.Dockerfile - volumes: - - ./bot/:/bot/ - env_file: - - ./env/bot-telegram.env - - ./env/bot.env - ports: - - 5005:5005 - command: sh -c "make telegram" - - # ============================ Grafana ======================================= - # Analytics - grafana: - image: grafana/grafana-enterprise - container_name: grafana - restart: unless-stopped - # if you are running as root then set it to 0 - # else find the right id with the id -u command - user: '1000' - ports: - - '3000:3000' - # adding the mount volume point which we create earlier - volumes: - - '$PWD/data:/var/lib/grafana' - - - - # =============================== Rocket.Chat ================================= - # Rocket.Chat instance. - rocketchat: - image: registry.rocket.chat/rocketchat/rocket.chat:latest - command: > - bash -c - "for i in `seq 1 30`; do - node main.js && - s=$$? && break || s=$$?; - echo \"Tried $$i times. Waiting 5 secs...\"; - sleep 5; - done; (exit $$s)" - restart: unless-stopped - volumes: - - ./uploads:/app/uploads - environment: - - PORT=3000 - - ROOT_URL=http://localhost:3000 - - MONGO_URL=mongodb://mongo-rocket:27017/rocketchat - - MONGO_OPLOG_URL=mongodb://mongo-rocket:27017/local - #- REG_TOKEN=${REG_TOKEN} - depends_on: - - mongo-rocket - ports: - - 3000:3000 - # =============================== Mongo ================================= - # Mongo database and replica set. - mongo-rocket: - image: mongo:4.0 - restart: unless-stopped - volumes: - - ./data/db:/data/db - command: mongod --smallfiles --oplogSize 128 --replSet rs0 --storageEngine=mmapv1 - - # this container's job is just run the command to initialize the replica set. - # it will run the command and remove himself (it will not stay running) - mongo-init-replica: - image: mongo:4.0 - command: > - bash -c - "for i in `seq 1 30`; do - mongo mongo/rocketchat --eval \" - rs.initiate({ - _id: 'rs0', - members: [ { _id: 0, host: 'localhost:27017' } ]})\" && - s=$$? && break || s=$$?; - echo \"Tried $$i times. Waiting 5 secs...\"; - sleep 5; - done; (exit $$s)" - depends_on: - - mongo-rocket - volumes: mongo_data: rocket_uploads: