Can't generate rasa Docker image from official RASA Dockerfile

Hey, i’m trying to generate a custom rasa Docker image from official Dockefile. There is no problem to generate the Docker image but when i want to train my chatbot with this next command (indicate in rasa documentation) :

root@ubuntu:/home/chatbot_rasa# docker run \
	-v $(pwd):/app \
	rasa/custom:latest \
	train \
		--domain domain.yml \
		--data data \
		--out models

The train start and stop without return error. Nothing is happening and no model is created:

2020-02-18 12:51:48 INFO     rasa.model  - Data (domain) for Core model section changed.
2020-02-18 12:51:48 INFO     rasa.model  - Data (messages) for NLU model section changed.
Processed Story Blocks: 100%|██████████| 28/28 [00:00<00:00, 4659.97it/s, # trackers=1]
root@ubunu:/home/ubuntu/chatbot_rasa#

Just one thing, i’m using a proxy and he’s configure in Dockerfile. How i can train my chatbot using Docker ? The aim is to install spacy FR. This is why I want to create custom rasa Docker Image.

Hi,

I have the same problem in this thread and nobody is asisting to help…

Maybe somoene will respond to us. I think there is a problem with their Dockefile. While to be answered, i’m training my chatbot with rasa installed from pip.

Yes, I also think that there is a problem with Dockerfile.

I locally trained the same code and generated desired model in /models directory easily.

I found a solution, take a look to my Dockerfile. I uninstall and install specific version of gym & sanic-plugins-framework python packages. And It working.

# Remove & install specific package version
RUN pip3 install -U pip
RUN pip3 uninstall -y gym
RUN pip3 install gym==0.15.4
RUN pip3 uninstall -y sanic-plugins-framework
RUN pip3 install sanic-plugins-framework==0.8.2

# Create common base stage
FROM python:3.6-slim as base

WORKDIR /build

# Create virtualenv to isolate builds
RUN python -m venv /build

# Install common libraries
RUN apt-get update -qq \
 && apt-get install -y --no-install-recommends \
    # required by psycopg2 at build and runtime
    libpq-dev \
     # required for health check
    curl \
 && apt-get autoremove -y

# Make sure we use the virtualenv
ENV PATH="/build/bin:$PATH"

# Stage to build and install everything
FROM base as builder

WORKDIR /src

# Install all required build libraries
RUN apt-get update -qq \
 && apt-get install -y --no-install-recommends \
    build-essential \
    wget \
    openssh-client \
    graphviz-dev \
    pkg-config \
    git-core \
    openssl \
    libssl-dev \
    libffi6 \
    libffi-dev \
    libpng-dev

# Upgrade pip
RUN pip install --upgrade pip

# Spacy FR installation 
RUN pip install https://github.com/explosion/spacy-models/releases/download/fr_core_news_sm-2.2.5/fr_core_news_sm-2.2.5.tar.gz --no-cache-dir > /dev/null \
	&& python -m spacy link fr_core_news_sm fr

# Copy only what we really need
COPY README.md .
COPY setup.py .
COPY setup.cfg .
COPY MANIFEST.in .
COPY requirements.txt .
COPY LICENSE.txt .

# Install Rasa and its dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Install Rasa as package
COPY rasa ./rasa
RUN pip install .[sql]

# Remove & install specific package version
RUN pip3 install -U pip
RUN pip3 uninstall -y gym
RUN pip3 install gym==0.15.4
RUN pip3 uninstall -y sanic-plugins-framework
RUN pip3 install sanic-plugins-framework==0.8.2

# Runtime stage which uses the virtualenv which we built in the previous stage
FROM base AS runner

# Copy virtualenv from previous stage
COPY --from=builder /build /build

WORKDIR /app

# Create a volume for temporary data
VOLUME /tmp

# Make sure the default group has the same permissions as the owner
RUN chgrp -R 0 . && chmod -R g=u .

# Don't run as root
USER 1001

EXPOSE 5005

ENTRYPOINT ["rasa"]
CMD ["--help"]

1 Like

Thank you for your help but I’m having trouble when running your docker file:

COPY README.md .
COPY setup.py .
COPY setup.cfg .
COPY MANIFEST.in .
COPY requirements.txt .
COPY LICENSE.txt .

# Install Rasa and its dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Install Rasa as package
COPY rasa ./rasa
RUN pip install .[sql]

# Remove & install specific package version
RUN pip3 install -U pip
RUN pip3 uninstall -y gym
RUN pip3 install gym==0.15.4
RUN pip3 uninstall -y sanic-plugins-framework
RUN pip3 install sanic-plugins-framework==0.8.2

I tried running it without your copy files that I do not have but then I get this error when installing/uninstalling stuff:

WARNING: The directory '/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

I suspect it could be because I do not have your files (setup/requirements…), would you mind sending them so I can try running everything? Thank you.

oh it’s rasa’s files :slight_smile: git clone rasa project and edit their Dockefile :wink:

git clone https://github.com/RasaHQ/rasa.git
cd rasa/
nano Dockerfile # Replace the content by my Dockerfile
docker build -t my/image .
1 Like

Thanks to this post, which solves my same problem. Here is what I’ve done:

  1. git clone https://github.com/RasaHQ/rasa.git

  2. In the rasa folder, edit Dockerfile as below

# Create common base stage
FROM python:3.6-slim as base

WORKDIR /build

# Create virtualenv to isolate builds
RUN python -m venv /build

# Install common libraries
RUN apt-get update -qq \
 && apt-get install -y --no-install-recommends \
    # required by psycopg2 at build and runtime
    libpq-dev \
    # required for health check
    curl \
 && apt-get autoremove -y

# Make sure we use the virtualenv
ENV PATH="/build/bin:$PATH"

# Stage to build and install everything
FROM base as builder

WORKDIR /src

# Install all required build libraries
RUN apt-get update -qq \
 && apt-get install -y --no-install-recommends \
    apt-utils \
    build-essential \
    wget \
    openssh-client \
    graphviz-dev \
    pkg-config \
    git-core \
    openssl \
    libssl-dev \
    libffi6 \
    libffi-dev \
    libpng-dev

# Make sure we have the latest pip version
RUN pip install -U pip

# Download mitie model
RUN wget -P /app/data/ https://s3-eu-west-1.amazonaws.com/mitie/total_word_feature_extractor.dat

# Copy only what we really need
COPY README.md .
COPY setup.py .
COPY setup.cfg .
COPY MANIFEST.in .
COPY alt_requirements/ ./alt_requirements
COPY requirements.txt .
COPY LICENSE.txt .

# Install dependencies
RUN pip install --no-cache-dir -r alt_requirements/requirements_full.txt

# Install and link spacy models
RUN pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_md-2.1.0/en_core_web_md-2.1.0.tar.gz#egg=en_core_web_md==2.1.0 --no-cache-dir > /dev/null && python -m spacy link en_core_web_md en

# Install Rasa as package
COPY rasa ./rasa
RUN pip install .[sql,spacy,mitie]

# Remove & install specific package version
RUN pip3 install -U pip
RUN pip3 uninstall -y gym
RUN pip3 install gym==0.15.4
RUN pip3 uninstall -y sanic-plugins-framework
RUN pip3 install sanic-plugins-framework==0.8.2

# Runtime stage which uses the virtualenv which we built in the previous stage
FROM base AS runner

WORKDIR /app

# Copy over default pipeline config
COPY sample_configs/config_pretrained_embeddings_spacy_duckling.yml config.yml

# Copy over mitie model
COPY --from=builder /app/data/total_word_feature_extractor.dat data/total_word_feature_extractor.dat

# Copy virtualenv from previous stage
COPY --from=builder /build /build

# Create a volume for temporary data
VOLUME /tmp

# Make sure the default group has the same permissions as the owner
RUN chgrp -R 0 . && chmod -R g=u .

# Don't run as root
USER 1001

EXPOSE 5005

ENTRYPOINT ["rasa"]
CMD ["--help"]
  1. Build your own docker:
docker build -t my/rasa:latest .
  1. Test it as below, it should work.
docker run -v $(pwd):/app my/rasa:latest init --no-prompt
docker run -it -v $(pwd):/app my/rasa:latest shell
2 Likes