0

I just started using docker to Docurize my django applications. I am using centos server to host my application. Now when first time I build docker image I got error on 'lxml' package so I removed it from requirements.txt file. But when I rebuild the image again 'lxml' is package still downloading

Here is my Dockerfile

FROM python:3.7.4-alpine3.10

ADD ConnectOneWeb/requirements.txt /app/requirements.txt

RUN set -ex \
    && apk add --no-cache --virtual .build-deps libffi-dev build-base \
    && apk add mariadb-dev \
    && apk add jpeg-dev \
    && python -m venv /env \
    && /env/bin/pip install --upgrade pip \
    && /env/bin/pip install --no-cache-dir -r /app/requirements.txt \
    && runDeps="$(scanelf --needed --nobanner --recursive /env \
        | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
        | sort -u \
        | xargs -r apk info --installed \
        | sort -u)" \
    && apk add --virtual rundeps $runDeps \
    && apk del .build-deps

ADD ConnectOneWeb /app
WORKDIR /app

ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH

EXPOSE 8000
CMD ["gunicorn", "--bind", ":8000", "--workers", "3", "ConnectOneWeb.wsgi:applic$

and my requirements.txt file

asgiref==3.2.3
bluesnap==1.2019.9.1
certifi==2018.4.16
cffi==1.13.2
chardet==3.0.4
cryptography==2.8
Django==3.0
django-anymail==7.0.0
django-countries==5.5
django-crontab==0.7.1
django-paypal==1.0.0
django-prometheus==1.1.0
gevent==1.4.0
greenlet==0.4.15
idna==2.7
Markdown==3.1.1
mysqlclient==1.4.6
pendulum==2.0.5
Pillow==6.2.1
prometheus-client==0.7.1
pycparser==2.19
pycryptodomex==3.9.4
pyOpenSSL==19.1.0
python-alipay-sdk==2.0.1
python-dateutil==2.8.1
pytz==2019.3
pytzdata==2019.3
requests==2.22.0
sentry-sdk==0.13.5
short-url==1.2.2
six==1.13.0
sqlparse==0.3.0
stripe==2.42.0
tomd==0.1.3
urllib3==1.25.7
uWSGI==2.0.18
xmltodict==0.12.0

As you can see there is no 'lxml' package in requirements.txt but I don't understand why it still download when building image

  • 1
    `lxml` is a dependency of `bluesnap`. It might be a dependency of other packages in your list too (I stopped at the first dependent package I found). – Zeitounator Feb 01 '20 at 14:44

1 Answers1

0

The solution to making your Docker build complete shouldn't be to delete required dependencies and continuing until it succeeds.

In this case, you presumably only need the dev versions of the system libraries to successfully install lxml on an Alpine base image.

Adding:

    && apk add libxml2-dev libxslt-dev \

at line 8 will do the trick in a away that is consistent with your current Dockerfile. (also see related post)

Jedi
  • 3,088
  • 2
  • 28
  • 47