Deploy my chatbot using docker

Hey @nik202 , How are you ? I need your help in deploying my bot using docker.As of now I have the GUI access of my linux VM.

@Rishabhh17 I am fine thanks for the concern. Can you answer some of my questions and please reply all:

  1. What is your front end as you are using rasa-webchat/botfront?
  2. Do you have a live website like Wordpress, Wix, Duda etc?
  3. Are your project is running while using rasa shell
  4. Are you using any kind of database i.e Postgres or MySQL etc
  5. Do you know how to work with ngrok?
  6. What is your linux VM i.e Ubuntu with GUI?

I hope you answer all my questions, so that I can help you the best ways.

@nik202

  1. rasa-webchat
  2. No
  3. Yes on terminal I can talk to my bot
  4. No not yet
  5. Just the command (ngrok http (port number)
  6. Yes (Ubuntu 18.04 with GUI)

@Rishabhh17 Thanks for sharing the answer with the prompt reply :stuck_out_tongue:

Well, the process I personally developed was all the 6 points mentioned above and my bot is working fine but as you replied you are using some points and some not. What I can help you for deploying the bot using docker image that means your rasa chatbot will run using docker container whilst using single command will that be fine with you Rishabh? Yes or No?

@nik202 will this allow my bot to up and running 24/7? Like rasa x does when we run (sudo docker-compose up -d )

@Rishabhh17 Well if you Ubuntu Server is running 24/7 then I guess yes as it will be running using docker container.

The command I also used will be docker-compose up --build and then docker-compose up -d

@Rishabhh17 If you want to know the solution do let me know please.

@nik202 ok then .I am ready

@Rishabhh17

Please find the steps as per our discussion:

Extra Step For Ubuntu: As Ubuntu Server not support docker desktop, Iā€™d suggest install VS code on Ubuntu machine, and add the docker extension for the same. There you will be able to see the docker details.

For Docker Environment:

  1. Create the Dockerhub ID from https://hub.docker.com

  2. Create a Docker image for action server by the name Dockerfile (blue logo), if you have any requirements, please make a requirement.txt file in the same folder with all the packages in it.

Snippet code:

FROM rasa/rasa-sdk:2.7.0
WORKDIR /app
COPY requirement.txt requirement.txt
USER root
RUN pip install -r requirement.txt
EXPOSE 5055
USER 1001

Note: If you did not require the requirement.txt file at the moment please commented

  1. Dockerfile for Rasa; create outside the actions folder where other related files by the name Dockerfile (blue logo)

Snippet code:

FROM rasa/rasa:2.7.1
WORKDIR  '/app'
COPY . /app
USER root

RUN  rasa train 

VOLUME /app/models


CMD [ "run","-m","/app/models","--enable-api","--cors","*","--debug" ,"--endpoints", "endpoints.yml", "--log-file", "out.log", "--debug"]

EXPOSE 5005
  1. Create the docker-compose.yml file same as you created the above file outside the actions folder by the name docker-compose.yml (pink logo)

Snippet code:

version: '3'
services:
    rasa:
      container_name: "rasa_server"
      user: root
      build: 
        context:  .
      volumes:
      - "./:/app"
      ports: 
        - "5005:5005"
    action_server:
      container_name: "action_server"
      build: 
        context: actions
      volumes:
        - ./actions:/app/actions
        - ./data:/app/data
      ports:
        - 5055:5055

Note: Update in endpoints.yml

action_endpoint:
  url: 'http://action_server:5055/webhook'

RUN the docker compose

  1. docker-compose up --build or after the build docker-compose up -d please see all the docker related commands.

  2. To check the container running or not docker ps or docker ps -a or docker-compose ps etc

  3. Copy a container from docker to localhost; run the command from terminal (should be in project folder)

docker cp <container ID or name>:"/app" "."

  1. Inspect the rasa server or action server as per need to see the content

docker exec -u root -t -i actions_server /bin/bash

Note: You will be able to run and execute all this whist if you are working on Window, Mac Or Ubuntu. If you have any issue whilst using this solution please mention me :wink:

This is my first ever so long post for any suggestion or solution with such a detail information. I hope it will solve your issue. Good Luck! Bro! Have fun :slight_smile:

Note: Please copy and paste with the current mentioned version we can change the versions at anytime later, but currently we are experimenting this process.

@nik202 Thankew So much Bro , It means a lot to me. :pray:

@Rishabhh17 As per your track record, I know you will be able to follow all the steps, but anytime you stuck, do let me know and please before mention the error, do check the above steps with spelling or even comma or dots ; that also can make our life tougher. All this you need to do in project folder only. The above mention process is the clean execution without any error as its developed and implemented by me. Good Luck!

@nik202 I am using a custom action. so I added a requirement.txt file having

requirement.txt
wolframalpha

Then I am having this below error

Building action_server
Step 1/7 : FROM rasa/rasa-sdk:2.7.0
 ---> 9681c32b59b0
Step 2/7 : WORKDIR /app
 ---> Using cache
 ---> 3bbe3bf6bdb4
Step 3/7 : COPY requirements.txt requirement.txt
 ---> f0a327731b05
Step 4/7 : USER root
 ---> Running in 52f3f911c9ae
Removing intermediate container 52f3f911c9ae
 ---> 0f0799138d6e
Step 5/7 : RUN pip install - r requirement.txt
 ---> Running in 79050c09ecd1
ERROR: Invalid requirement: '-'
WARNING: You are using pip version 21.1.2; however, version 21.2.4 is available.
You should consider upgrading via the '/opt/venv/bin/python -m pip install --upgrade pip' command.
ERROR: Service 'action_server' failed to build: The command '/bin/bash -o pipefail -c pip install - r requirement.txt' returned a non-zero code: 1

@Rishabhh17 you can even mention the wolframalpha with the version whilst using ==

@Rishabhh17 what you have done in requirement using ERROR: Invalid requirement: ā€˜-ā€™ ??

@nik202 I have mentioned the same as when installed using pip.

@Rishabhh17 OMGGGGGG check the spelling bro

Step 3/7 : COPY requirements.txt requirement.txt

I asked to copy and paste the code and still the error :frowning:

@nik202 I have done the copy paste. :roll_eyes:

@nik202

Step 3/7 : COPY requirements.txt requirement.txt
ERROR: Service 'action_server' failed to build: COPY failed: file not found in build context or excluded by .dockerignore: stat requirements.txt: file does not exist

@Rishabhh17 where you have mentioned the requirement file is it in action folder or outside?

@nik202 Its inside the actions folder ,actually there are in the actions folder these files.

/home/azureuser/smart_hr/actions/__pycache__
/home/azureuser/smart_hr/actions/__init__.py
/home/azureuser/smart_hr/actions/actions.py
/home/azureuser/smart_hr/actions/Dockerfile
/home/azureuser/smart_hr/actions/requirement.txt

Hii @nik202 , Good Morning, You there?

@Rishabhh17 Thanks and same to you Tell ? @Rishabhh17 All good?