2

I'm trying to create a dockerfile for a flask-based python app which relies heavily on haystack. The file reads as follows:

FROM python:3.9

WORKDIR /app # setting the docker working directory

COPY . / # copying all python files, requirements.txt etc from the folder

RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt # this includes farm-haystack


EXPOSE 5000 # this is a flask-based app, so I want to run a local instance on port 5000

ENTRYPOINT [ "python" ]

CMD [ "app.py" ] # the main file of the app, which tries but fails to load in the haystack library

When running the docker container, it throws module not found errors for haystack modules (but not for any of the others) on import attempts right at the beginning of the file.

I'm trying to run this on an Apple M1 laptop, want it to be platform agnostic though, so that the docker container can easily be shared with others working in different OS environments.

Any help or advice would be greatly appreciated!

Philo
  • 51
  • 5
  • Please post the exact error message. If you want fast feedback from haystack developers and community, you can join discord channel: https://haystack.deepset.ai/community/join – Stefano Fiorucci - anakin87 Aug 17 '22 at 09:52
  • Thanks for the response! The error message reads: "ModuleNotFoundError: No module named 'haystack.document_stores'", although this can be replicated with literally any haystack module. – Philo Aug 17 '22 at 10:00
  • If you can share your requirements.txt and the failing part of app.py, it could help to understand better... – Stefano Fiorucci - anakin87 Aug 17 '22 at 10:04
  • Requirements.txt: click==8.1.3 Flask==2.2.1 gunicorn==20.1.0 importlib-metadata==4.12.0 itsdangerous==2.1.2 Jinja2==3.1.2 MarkupSafe==2.1.1 Werkzeug==2.2.1 zipp==3.8.1 elasticsearch>=7.17.4 pandas protobuf==3.20.* flask-cors sqlalchemy farm-haystack the import fails on the third line of app.py: "from haystack.document_stores import ElasticsearchDocumentStore" The preceding two lines import other libraries without issue. Importing said module (or other haystack modules) on the first line doesn't change things. – Philo Aug 17 '22 at 10:08

1 Answers1

1

This turned out to be a simple dependency issue. To solve, simply change requirements to:

elasticsearch==7.10.1

farm-haystack==1.6.0

Philo
  • 51
  • 5