Extending rasa docker for a new spacy language model

Hi,

I’m using the docker guide at https://rasa.com/docs/rasa/docker/building-in-docker which mentions “If your model has a dependency that is not included in any of the tags (for example, a different spaCy language model), you can build a docker image that extends the rasa/rasa image.”

I would like to add the Dutch language, so I’ve made a custom Dockerfile containing these lines:

FROM rasa/rasa:1.10.14-full

RUN python -m spacy download nl_core_news_sm
RUN python -m spacy link nl_core_news_sm nl

(The commands come from https://legacy-docs-v1.rasa.com/user-guide/installation/#dependencies-for-spacy)

However, upon building my image I get an error:

docker build -t rasatest .

Step 1/3 : FROM rasa/rasa:1.10.14-full
---> b66c2b6e4182
Step 2/3 : RUN python -m spacy download nl_core_news_sm
 ---> Running in 291b375217bc
Collecting nl_core_news_sm==2.1.0
  Downloading https://github.com/explosion/spacy->
models/releases/download/nl_core_news_sm-2.1.0/nl_core_news_sm2.1.0.tar.gz (11.3MB)
Building wheels for collected packages: nl-core-news-sm
Building wheel for nl-core-news-sm (setup.py): started
Building wheel for nl-core-news-sm (setup.py): finished with status 'done'
Created wheel for nl-core-news-sm: filename=nl_core_news_sm-2.1.0-cp37-none-any.whl size=11289434 sha256=d73997d392350bf7710f5c766fa01aa7f2a83a7b5da958b8eb0619c590886bb7
Stored in directory: /tmp/pip-ephem-wheel-cache-qlbr56wf/wheels/48/98/b8/eb89625dcd24a84c4204c5d8e0089bf0df77cc085a6650dff9
Successfully built nl-core-news-sm
Installing collected packages: nl-core-news-sm
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/opt/venv/lib/python3.7/site-packages/nl_core_news_sm-2.1.0.dist-info'
Consider using the `--user` option or check the permissions.
WARNING: You are using pip version 19.3.1; however, version 20.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/bash -o pipefail -c python -m spacy download nl_core_news_sm' returned a non-zero code: 1

What am I supposed to do to fix this? Seems to be an issue with the original rasa image?

Best regards!

Found it, on one of the other rasa pages… so too well hidden.

I have to change from user 1001 to root first, and then go back. The final Dockerfile is:

FROM rasa/rasa:1.10.14-full

# Change back to root user to install dependencies
USER root

RUN python -m spacy download nl_core_news_sm
RUN python -m spacy link nl_core_news_sm nl

# Switch back to non-root to run code
USER 1001
3 Likes