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
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
- 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:
- 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
- Familiarize yourself with the flags you may need to run with your Rasa container (lines 98-103)
- 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.
- 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.
- 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.
- 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.
- 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)
- 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:
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.