Rasa Open Source in Docker-Compose with Action Server

Hello All,

I started working with Rasa open source a little while ago, and I ran into a lot of hurdles getting it up and running in my docker-compose environment. There were bits and pieces of advice and guides scattered all over the internet including in these forums, but I wanted to share how I got it working so if anyone else is working on a similar project, they may gain some insight from this.

I stripped down my docker-compose environment to the very barebones and tried to make the environment as easy to modify as possible.

My minified docker-compose environment

All of the code lives here GitHub - cskujawa/rasa-assistant

Hurdles

I really want to cover some of the hurdles I had and try to use keywords so if anyone else is searching for solutions they can easily find them too.

Rasa Open Source Docker Container

Getting started with just the open source Rasa Docker container was relatively easy, but there were a few hurdles

  1. First, make sure you set a user (line 88) if you’re not running your docker-compose as root, this will prevent running into errors like:
  2. Be aware of the model you’re trying to use for training as it may have a specific tag, for instance I’m using rasa/rasa:main-spacy-en
  3. Familiarize yourself with the flags you may need to run with your Rasa container (lines 98-103)
  4. Know that rasa won’t train itself in docker, while there may be elegant solutions to this, for the time being, when I need to train instead of start the container I change line 99 to “- train” instead of “- run”, let it finish (it will exit when done), then switch it back and start the container again.
  5. Postgres ended up being the best solution for my Tracker Store, I was unable to get redis working for it, and MySQL containers are poorly optimized for Docker, but be wary of having Rasa start before the tracker store DB is actually running. I used Docker’s healthcheck (lines 151-155) and a “depends_on postgres service_healthy” (lines 106-108) statement to ensure the DB was up before Rasa started.
  6. Use the Docker container name of your DB in the endpoints.yml and the formatted URL for the action_endpoint url in the same file.
  7. If you’re going to use Rasa to parse out bits and pieces from phrases, get familiar with slots (lines 48-60)/entities (lines 44-46)/and their usage in actions (lines 21-44).

Rasa-SDK Docker Container

For the Rasa-SDK container, the hurdles were a little more challenging.

  1. Be prepared to extend the container, for me I needed to extend it to use the user I wanted, and install the requests package needed to make external API calls to other docker containers (lines 11-18)
  2. You may want to set the working directory as app and not actions, then manually tell the container to execute --actions actions (line 121) to pre-empt issues like:

Closing Thoughts

Most importantly if you’re just geting started with Rasa, review the examples the Rasa team provided, getting familiar with how different Rasa deployments work before just jumping in could save you a lot of time. Secondly, read the docs as far as you can, it could save you a lot of time.

Ultimately, I set out to try and create an assistant that would be able to perform whatever functions I wanted it to, control my home’s IoT devices, and just be a fun project, and Rasa was instrumental to my success in all of that. Big thank you to the Rasa team.

I hope this finds whoever may need it in the future.

1 Like