1

I am trying to build an image for one of my program which has the dependencies on numpy, sklearn, matplotlib and flask. I have kept all these dependencies in the requirements.txt file as

flask
matplotlib==3.3.4
numpy==1.20.1
sklearn==0.0

In my Dockerfile I wrote the following commands:

FROM alpine

WORKDIR /usr/src/app

RUN apk add python3 py3-pip

COPY requirements.txt ./

RUN pip install -r requirements.txt

COPY . .

CMD ["python3", "./app.py"]

CMD ["python3", "./web.py"]

while building it with command docker build -t cluster-ml ., at step 5/8 i.e. in install requirements.txt, it gets stuck when installing matplotlib like forever. What is that I am doing wrong?

Uvular
  • 11
  • 3
  • If you wait long enough, chances are you'll get a very long error output, starting with a warning `the wheel package is not available` followed by a tentative to compile every single needed dependencies for matplotlib. A quick search on the web for `alpine python wheel` leads to [this top result](https://pythonspeed.com/articles/alpine-docker-python/) explaining what you are actually facing. Your choices now: 1) follow the dependency spaghetti to install every single needed build tool and dev package to compile to the end 2) choose a different base image that has `python(x)-wheels` available. – Zeitounator Sep 05 '21 at 08:55
  • Totally unrelated note: your Dockerfile has two `CMD` stanza. Only the last one will be retained. – Zeitounator Sep 05 '21 at 08:56

0 Answers0