spaCy and Docker: can’t "dockerize" Flask app that uses spaCy modules

  docker, python, spacy

I’m trying to install SpaCy on my docker image but it always fails. First it was on my requirements.txt file, but it failed right away. Later on I tried running a separate RUN instruction for pip to install it in isolation but it also failed.

Here’s my Dockerfile content:

FROM python:3.6-alpine
WORKDIR /sentenceSimilarity
ADD . /sentenceSimilarity
RUN pip install -r requirements.txt
RUN pip install -U pip setuptools wheel
RUN pip install -U spacy
RUN python -m spacy download en_core_web_sm
CMD ["python", "app.py"]

I ended up deleting everything from my requirements.txt file except for Flask and the issue is always stumbled upon the line in which Spacy comes, the only difference now is that it takes a huge time to fail. See screenshot:

enter image description here

Observing a bit, I think pip has been iterating to check which version might suit, from newest to oldest. But none of those at the end gets installed.

I’ve seen others with similar issues with SpaCy, but no apparent solution.

Can someone suggest an approach I could use to fix this? Thanks in advance.

Source: Docker Questions

LEAVE A COMMENT