I am having issues with running a rasa chatbot flask app in docker. I have used botfront script in index.html to make a flask app that will give a GUI for my rasa chatbot. The chatbot I am trying to implement right now is just the basic rasa init chatbot. I am facing some issues when running the docker-compose up command.
Goal
To run rasa flask app via docker.
Current Issue
The app server is shown as running, but it is not visible on the mentioned address.
Error
Starting rasa-chat-app … done
Starting rasa-chatbot-server … done
Attaching to rasa-chat-app, rasa-chatbot-server
rasa-chat-app | * Serving Flask app ‘app’ (lazy loading)
rasa-chat-app | * Environment: production
rasa-chat-app | WARNING: This is a development server. Do not use it in a production deployment.
rasa-chat-app | Use a production WSGI server instead.
rasa-chat-app | * Debug mode: on
rasa-chat-app | * Running on all addresses.
rasa-chat-app | WARNING: This is a development server. Do not use it in a production deployment.
rasa-chat-app | * Running on http://172.18.0.3:8000/ (Press CTRL+C to quit)
rasa-chat-app | * Restarting with stat
rasa-chat-app | * Debugger is active!
rasa-chat-app | * Debugger PIN: 143-584-386
rasa-chatbot-server | Matplotlib created a temporary config/cache directory at /tmp/matplotlib-e9aqxszg because the default path (/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
rasa-chatbot-server | 2021-07-06 07:37:38 WARNING rasa.utils.common - Failed to write global config. Error: [Errno 13] Permission denied: ‘/.config’. Skipping.
rasa-chatbot-server | 2021-07-06 07:37:38 INFO root - Starting Rasa server on http://localhost:5005
rasa-chatbot-server | 2021-07-06 07:37:38 INFO rasa.model - Loading model models/20210425-161726.tar.gz…
rasa-chatbot-server | 2021-07-06 07:37:50 INFO root - Rasa server is up and running.
rasa-chat-app | 172.18.0.1 - - [06/Jul/2021 08:19:51] “GET / HTTP/1.1” 200 -
rasa-chat-app | 172.18.0.1 - - [06/Jul/2021 08:19:51] “GET /favicon.ico HTTP/1.1” 404 -
Files
Docker-compose file
version: '2' services: rasa-flask:
image: rasa-chatbot:latest
build:
context: .
dockerfile: Dockerfile
container_name: rasa-chat-app
volumes:
- .:/rasa_app
ports:
- 5000:5000
command: python3 app.py rasa-server:
image: rasa/rasa:2.1.2-full
container_name: rasa-chatbot-server
volumes:
- .:/app
ports:
- 5005:5005
command: run -m models --enable-api --cors "*"
DockerFile
FROM tensorflow/tensorflow:2.2.0
RUN mkdir -p /rasa_app
WORKDIR /rasa_app
COPY . /rasa_app
RUN python -m pip install -U pip
RUN pip3 install -r requirements.txt
#RUN pip3 install --user rasa-nlu==0.14.0
#RUN pip3 install --user rasa-core==0.13.2
RUN python -m spacy download en
RUN pip3 install --user rasa==2.1.2
RUN pip3 install --user sanic==19.9.0
Flask App file
from flask import Flask
from flask import render_template
# creates a Flask application, named app
app = Flask(__name__, static_url_path='/static')
# a route to display our html page gotten from [react-chat-widget](https://github.com/mrbot-ai/rasa-webchat)
@app.route("/")
def index():
return render_template('index.html')
# run the application
if __name__ == "__main__":
app.run(host="0.0.0.0", port="8000", debug=True)
HTML file
<!doctype html>
<html>
<head>
</head>
<body>
<script>!(function () {
let e = document.createElement("script"),
t = document.head || document.getElementsByTagName("head")[0];
(e.src =
"https://cdn.jsdelivr.net/npm/rasa-webchat@1.0.0/lib/index.js"),
// Replace 1.x.x with the version that you want
(e.async = !0),
(e.onload = () => {
window.WebChat.default(
{
customData: { language: "en" },
socketUrl: "http://localhost:5005",
// add other props here
},
null
);
}),
t.insertBefore(e, t.firstChild);
})();
</script>
</body>
</html>