Ошибка при установке библиотеки crispy python с колесами в докер-образ python:3.10.5-alpine
Ахой
Я пытался создать образ docker из Docker-файла моего приложения djanog. В dockerfile я сначала использую билдер для установки библиотек из файла requirements.txt с помощью wheel. При установке библиотеки crispy возникает ошибка ModuleNotFoundError: No module named 'silx'. Библиотека silx также находится в файле requirements.txt, но устанавливается позже. Я также попытался поместить запись silx в файл requirements.txt перед библиотекой crispy, но ошибка все равно возникает.
команда docker для сборки образа:
docker build . --progress=plain
Вот ошибка, когда я пытаюсь построить образ:
Collecting crispy==0.7.3
Downloading crispy-0.7.3.tar.gz (409 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 409.6/409.6 KB 106.5 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-wheel-9r0etvcg/crispy_5ce9bef2b34f47b19aabc37ccd7cfab8/setup.py", line 149, in <module>
main()
File "/tmp/pip-wheel-9r0etvcg/crispy_5ce9bef2b34f47b19aabc37ccd7cfab8/setup.py", line 77, in main
version=get_version(),
File "/tmp/pip-wheel-9r0etvcg/crispy_5ce9bef2b34f47b19aabc37ccd7cfab8/setup.py", line 53, in get_version
from crispy import version
File "/tmp/pip-wheel-9r0etvcg/crispy_5ce9bef2b34f47b19aabc37ccd7cfab8/crispy/__init__.py", line 3, in <module>
from silx.resources import register_resource_directory
ModuleNotFoundError: No module named 'silx'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
WARNING: You are using pip version 22.0.4; however, version 22.2.1 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
Вот мой Dockerfile:
###########
# BUILDER #
###########
# pull official base image
FROM python:3.10.5-alpine as builder
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install psycopg2 dependencies
#RUN apk update \
# && apk add postgresql-dev gcc python3-dev musl-dev
RUN apk update \
&& apk add --virtual build-deps gcc python3-dev musl-dev \
&& apk add --no-cache mariadb-dev \
&& apk add --no-cache mariadb-connector-c-dev
# lint
#RUN pip install --upgrade pip
#RUN pip install flake8==3.9.2
#COPY . .
#RUN flake8 --ignore=E501,F401 .
# install dependencies
COPY ./requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
#RUN apk del build-deps
#########
# FINAL #
#########
# pull official base image
FROM python:3.10.5-alpine
# create directory for the app user
RUN mkdir -p /home/app
# create the app user
RUN addgroup -S app && adduser -S app -G app
# create the appropriate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
RUN mkdir $APP_HOME/staticfiles
RUN mkdir $APP_HOME/mediafiles
WORKDIR $APP_HOME
# install dependencies
RUN apk update && \
apk add libpq \
&& apk add --no-cache mariadb-dev \
&& apk add --no-cache mariadb-connector-c-dev
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --no-cache /wheels/*
# copy entrypoint.sh
COPY ./entrypoint.sh .
RUN sed -i 's/\r$//g' $APP_HOME/entrypoint.sh
RUN chmod +x $APP_HOME/entrypoint.sh
# copy project
COPY . $APP_HOME
# chown all the files to the app user
RUN chown -R app:app $APP_HOME
# change to the app user
USER app
# run entrypoint.sh
#ENTRYPOINT ["/home/app/web/entrypoint.sh"]
Ошибка происходит в строке:
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
А также файл requirements.txt:
aiohttp==3.8.1
aiosignal==1.2.0
asgiref==3.5.2
async-timeout==4.0.2
attrs==22.1.0
beautifulsoup4==4.11.1
charset-normalizer==2.1.0
crispy==0.7.3
crispy-bootstrap5==0.6
cycler==0.11.0
Django==4.0.6
django-crispy-forms==1.14.0
django-mysql==4.7.0
django-resized==1.0.1
fabio==0.14.0
fontawesomefree==6.1.2
fonttools==4.34.4
frozenlist==1.3.0
gunicorn==20.1.0
h5py==3.7.0
idna==3.3
kiwisolver==1.4.4
matplotlib==3.5.2
multidict==6.0.2
mysqlclient==2.1.1
numpy==1.23.1
packaging==21.3
Pillow==9.2.0
psycopg2-binary==2.9.3
pyparsing==3.0.9
PyQt5==5.15.7
PyQt5-Qt5==5.15.2
PyQt5-sip==12.11.0
python-dateutil==2.8.2
silx==1.0.0
six==1.16.0
soupsieve==2.3.2.post1
sqlparse==0.4.2
tzdata==2022.1
yarl==1.7.2