Multiple Rasa containers with docker-compose (part 1)

Setting up multiple Rasa instances with docker-compose

Our customer has two different chatbots with distinct functions. One is a site support chatbot, with knowledge of the site itself and can open support tickets for the humans that run the site. The other is a general knowledge chatbot that answers questions about the customers business, related to realtors.

Here's how we got the chatbots up and running on the same server using docker containers.

The setup is under RHEL7 (CentOS). We'll use docker containers and docker-compose to make life easier. 

In the end, there will be 5 containers running:
  • Chatbot A
  • Action server A
  • Chatbot B
  • Action server B
  • mongoDB

Setting up the file system

Create a folder, let's say app, and create a folder for each chatbot (we'll call them chatbot_a and chatbot_b).

Copy your chatbot configuration files into the separate folders, but leave the trained models out for the moment. We want a folder structure like this:


chatbot_a, chatbot_b and both action folders will be separate containers, and are marked in blue. The model_a and model_b folders are outside of the chatbot folders, because we want to copy the model to the container when it starts up instead of creating a new container.

Setting up the containers

First we need to create an image with rasa installed, and it will be used as a base for all 4 Rasa containers. For this you'll need a docker account.

Here's the dockerfile for our base container:

FROM python:3.6-slim

RUN apt update && apt install -y gcc make

RUN python3 -m pip install --upgrade pip

COPY ./requirements.txt /tmp

RUN pip3 install --no-cache-dir --default-timeout=1000 -r /tmp/requirements.txt

RUN python -m spacy download pt_core_news_sm

RUN python -m spacy link pt_core_news_sm pt --force

RUN python3 -c "import spacy; spacy.load('pt');"

RUN python3 -c "import nltk; nltk.download('stopwords');"

Note that we use portuguese in Brazil, and Rasa with Spacy. In some of our actions we use nltk, but if you don't use them, you can remove the last line.

And here's the requirements.txt:

rasa[spacy]==1.4.6
nltk==3.4.4
simplejson==3.17.0

Let's build our container (calling it rasabase) and push it to Docker Hub (sscudder is my docker user):

$docker build -t rasabase .
$docker push sscudder/rasabase

We'll be using this in all the other containers (except mongoDB).

Comments

Popular posts from this blog

Better report for Rasa chatbot model analysis

Multiple Rasa containers with docker-compose (part 2)