I\'ve noticed that installing Pandas and Numpy (it\'s dependency) in a Docker container using the base OS Alpine vs. CentOS or Debian takes much longer. I created a little t
This worked for me:
FROM python:3.8-alpine
RUN echo "@testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk add --update --no-cache py3-numpy py3-pandas@testing
ENV PYTHONPATH=/usr/lib/python3.8/site-packages
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5003
ENTRYPOINT [ "python" ]
CMD [ "app.py" ]
Most of the code here is from the answer of jtlz2 from this same thread and Faylixe from another thread.
Turns out the lighter version of pandas is found in the Alpine repository py3-numpy
but it doesn't get installed in the same file path from where Python reads the imports by default. Therefore you need to add the ENV
. Also be mindful about the alpine version.