Skip to content

Build your docker image

Omid Foroqi edited this page Sep 7, 2021 · 9 revisions

Installation guide

Clone Rasa branch

git clone https://github.com/MedBot-team/NaBot --single-branch --depth 1

Directory tree

To run the Rasa chatbot, we need to run actions-server and chatbot-server separately. So we've separated actions, datasets, and chatbots from each other.

Action-Server will contain actions and datasets, and Rasa-Server will contain the chatbot model and its autocorrect component.

production/
├── action-server
│   ├── actions
│   └── docker
├── datasets-server
├── events-server
├── monitoring-server
│   └── monitoring_ui
├── nginx
├── rasa-server
│   ├── docker
│   └── rasa
│       ├── data
│       ├── dictionary
│       ├── domain
│       ├── tests
│       └── train_test_split
└── streamlit-server
    └── streamlit

In the rest of the document, we will build separated images for actions and rasa and then run them together.

Create .env file

Create .env file, with this sample

$ cat production/.env
TOKEN=$MY_TOKEN
MYSQL_DATASETS_ROOT_PASSWORD=$MY_DATASETS_DATABASE_PASSWORD
MYSQL_EVENTS_ROOT_PASSWORD=$MY_EVENTS_DATABASE_PASSWORD
RASA_SERVER_URL=http://rasa:5005/webhooks/rest/webhook
SQL_USER=root
DATASETS_DB_HOST=db_datasets
EVENTS_DB_HOST=db_events
MYSQL_DATASETS_DATABASE=datasets
MYSQL_EVENTS_DATABASE=rasa
DRUG_TABLE=drugs
LAB_TABLE=labs
ACTION_HOST=app
TELEGRAM_ACCESS_TOKEN=$MY_TELEGRAM_TOKEN
TELEGRAM_VERIFY=$MY_TELEGRAM_BOT_ID
TELEGRAM_WEBHOOK_URL=$MY_API_SERVER_URL/webhooks/telegram/webhook

Choose your Dockerfile

  1. Default Dockerfile is Slim-based. But you can choose other Dockerfiles in the docker directory. For example for the rasa-based images:
cp production/rasa-server/docker/Dockerfile-Rasa production/rasa-server/Dockerfile
cp production/action-server/docker/Dockerfile-Rasa production/action-server/Dockerfile

Review docker-compose file

  1. In the case of using an old version of docker-compose or docker-engine, you might need to add the version key, on top of the docker-compose.yml file. For example in the case of the 1.25.0 version of docker-compose, you need to add version: "3.7" or version: "3" on top of your docker-compose file like this:
version: "3.7"
services:
  rasa:
    build:
      context: ./rasa-server
      dockerfile: Dockerfile
      args:
        - VERSION=v0.1.0
.
.
.
  1. Also the version of the model weights you want to use, can be assigned by the VERSION argument in the docker-compose file. This will download the VERSION.tar.gz file from Dropbox while building Docker images.

    Please note that, if you want to use the special version of our bot, you should clone that version alongside assigning that version as the VERSION argument in the docker-compose file. you can find out available versions here

Build an image

  1. Build a rasa chatbot and action server images
docker-compose -f production/docker-compose.yml build

Make containers and run images

  1. Run docker-compose to start and run the chatbot and its actions together in an isolated environment
docker-compose -f production/docker-compose.yml up -d

Test your chatbot

  1. with the examples in Test your chatbot page

Monitor the chatbot

  1. Check for errors and warnings in logs
docker-compose -f production/docker-compose.yml logs -f -t
  1. Monitor a live stream of containers resource usage statistics
docker stats

In removing the chatbot case

  1. Stop and remove chatbot containers
docker-compose -f production/docker-compose.yml down

Clone this wiki locally