How to build a Rasa server image in docker

I want to run a rasa server in docker, so I write a Dockerfile, and then I use docker build command to build my docker image:

docker build -t Tag:1.0 .

But I receive errors as follows:

ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/build/lib/python3.6/site-packages/pandas-1.0.1.dist-info'
Consider using the `--user` option or check the permissions.

My Dockerfile Attached:

FROM rasa/rasa:1.7.0-full

WORKDIR /app

COPY ./requirements.txt ./

RUN pip install -r requirements.txt -i https://pypi.doubanio.com/simple/ --no-cache-dir

COPY ./actions /app/actions
COPY ./models /app/models

COPY ./data/nlu/lookups/stock.txt /app/data/nlu/lookups/stock.txt

COPY ./data/nlu/lookups/focus_group.txt /app/data/nlu/lookups/focus_group.txt

COPY ./intent_description_mapping.csv /app/intent_description_mapping.csv
COPY ./endpoints.yml /app/endpoints.yml

CMD ["run", "-m", "models/MITIE_20200211-222726.tar.gz", "--endpoints", "endpoints.yml"]

Thank you for help!

The Rasa Open Source images don’t run as root by default. You have to switch to the root user before installing your other requirements. You can do by doing:

FROM rasa/rasa:1.7.0-full
USER root

# Rest of your dockerfile
1 Like

Great, thank you @Tobias_Wochinger, it is useful for me!

I can build docker image, but when I run my imges:

docker run image:tag

I met error:

Exception: Unable to load total_word_feature_extractor detector from data/total_word_feature_extractor_zh.dat

My config file:

language: zh
pipeline:
- name: "MitieNLP"
  model: "data/total_word_feature_extractor_zh.dat"
- name: JiebaTokenizer
  dictionary_path: "data/nlu/lookups"
- name: RegexFeaturizer
- name: MitieEntityExtractor
- name: CountVectorsFeaturizer
  OOV_token: oov
  token_pattern: (?u)\b\w+\b
- name: CountVectorsFeaturizer
  analyzer: char_wb
  min_ngram: 1
  max_ngram: 4
- name: EmbeddingIntentClassifier
  epochs: 50
  loss_type: margin
- name: DucklingHTTPExtractor
  url: http://localhost:8000
  dimensions:
  - number
  - amount-of-money
  locale: "zh"
  timezone: "CN"
- name: EntitySynonymMapper
policies:
- name: EmbeddingPolicy
  max_history: 10
  epochs: 20
  batch_size:
  - 32
  - 64
#- max_history: 6
#  name: AugmentedMemoizationPolicy
- core_threshold: 0.3
  name: TwoStageFallbackPolicy
  nlu_threshold: 0.8
- name: FormPolicy
- name: MappingPolicy

my Dockerfile:

FROM rasa/rasa:1.7.0-full
USER root

WORKDIR /app

COPY ./requirements.txt ./

RUN pip install -r requirements.txt -i https://pypi.doubanio.com/simple/ --no-cache-dir

COPY ./actions /app/actions
COPY ./models /app/models
COPY ./data /app/data

COPY ./intent_description_mapping.csv /app/intent_description_mapping.csv
COPY ./endpoints.yml /app/endpoints.yml

CMD ["run", "-m", "models/MITIE_20200211-222726.tar.gz", "--endpoints", "endpoints.yml"]

Do you know how to solve it? @Tobias_Wochinger

This seems like you are using the mitie pipeline, correct? I think the issue is that the COPY ./data /app/data overwrites the directory where the mitie word features file is stored. I’d suggest to try a different directory for your data folder

It is fixed now! Thank you for your answer, the problem is caused that I upload not complete total_word_feature_extractor_zh.dat file.

:tada:

Hello @Tobias_Wochinger, I would like to thank you about answering these questions, that helps me a lot. I have an issue when I’m trying to deploy my docker image of RASA in heroku. here is the screenshot:

How I can avoid this large size: Here is my dockerfile content:

FROM rasa/rasa:1.10.2-full WORKDIR /app COPY . /app EXPOSE 5005 CMD [“run”, “–cors”, “*”, “–debug”]

@yassine.lamarti

Unfortunately the Docker images are quite large due to the included language model. The image with the postfix --full includes models for multiple different NLU components, so you can save space if use / build one which only includes the dependencies for your pipeline.

I’m not really familiar with Heroku, but I saw that Docker images are not subject to the size restrictions:

While Docker images are not subject to size restrictions (unlike slugs), they are subject to the dyno boot time restriction. As layer count/image size grows, so will dyno boot time. See the best practices for writing Dockerfiles guide for suggestions on how to reduce Docker image size.

This means that the issue shouldn’t be there in the first place :thinking: Can you maybe double check if the way you’re uploading the images is as described by Heroku?

Thank you @Tobias_Wochinger for your quick answer. I would like to ask you about 2 topics: 1) You said that you are not familiar with Heroku, Do you an alternative of Heroku which is free? if yes, can you share it Please, I tried to follow the Ep #11 of Rasa Masterclass or this one : deploy it with RAsa webchat, with Google cloud platform but it doesn’t work.

  1. you said : “you can save space if use / build one which only includes the dependencies for your pipeline.” But I didn’t understand what you meant by “use / build”, In based on the large size of rasa with this image ‘rasa/rasa:1.10.2-full’ I tried to apply your advice and use another tag which can be with less size, but it doesn’t work. here is the screenshot of the 2 tags of RASA that I used: .

My goal is to deploy my chatbot into my website with any free way ( not specifically with heroku). can you help me please?

You said that you are not familiar with Heroku, Do you an alternative of Heroku which is free?

Unfortunately no. Maybe someone else from the community can help you. AWS usually offers some free credit to get started with, but you’ll have to pay eventually, too.

I tried to apply your advice and use another tag which can be with less size, but it doesn’t work. here is the screenshot of the 2 tags of RASA that I used:

That’s an outdated and deprecated version! Please don’t use that one!

Did you read through the documentation of Heroku to check if you’re uploading the Docker images correctly?

Hello @Tobias_Wochinger, Yes I read it, but there is no solution for my situation because Tensorflow is necessary for RASA, and only tensorflow have more than 500 MB in his size on his docker’s compressed size . I had an idea to extract just dependencies that RASA needs from Tensorflow but I didn’t know how.

So you pushed the image as described here? :grimacing:

Thank you @Tobias_Wochinger for your help, I think that Heroku isn’t the best choice, I have to find another platform .

Hi @yassine.lamarti,

please let us know about your final decision. I think that would be valuable and helpful for the community and us! :pray: