从docker中的pipfile.lock安装时发生错误

时间:2019-06-09 10:02:05

标签: python django docker dockerfile django-channels

我正在尝试在项目中使用docker。除非我使用django频道和Pillow,否则一切正常。下面是我的工作配置

Dockerfile

FROM python:3.7-alpine

ENV PYTHONUNBUFFERED 1
ENV PYTHONDONTWRITEBYTECODE 1

# set working directory which will be inside ubuntu
WORKDIR /code

#### Install a dependency ####
# install psycopg2
RUN echo "https://mirror.csclub.uwaterloo.ca/alpine/v3.9/main" > /etc/apk/repositories
RUN echo "https://mirror.csclub.uwaterloo.ca/alpine/v3.9/community" >>/etc/apk/repositories
RUN apk update
RUN apk add --update --no-cache postgresql-client jpeg-dev
RUN apk add --update --no-cache --virtual .tmp-build-deps \
    gcc libc-dev linux-headers postgresql-dev musl-dev zlib zlib-dev \
    && pip3 install psycopg2-binary \
    && apk del .tmp-build-deps

RUN pip3 install --upgrade pip
RUN pip3 install pipenv
COPY Pipfile* /code/
RUN pipenv install --system --deploy --ignore-pipfile
COPY ./entrypoint.sh /code/entrypoint.sh
COPY . /code/

ENTRYPOINT ["/code/entrypoint.sh"]

我的pipfile是

[packages]
django = "*"
"psycopg2-binary" = "*"
djangorestframework = "*"
djangorestframework-jwt = "*"
djoser = "*"
graphene-django = "*"
django-cors-headers = "*"
django-graphql-social-auth = "*"
django-money = "*"
django-mptt = "*"
pillow = "*"
channels = "*"
channels-redis = "*"

我得到的错误是这样的

enter image description here

如果我从pipfile中删除了枕头,通道和通道-redis,它会起作用。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

根据我的经验,像这样的错误通常是由于缺少传递的本机依赖性而导致的。根据错误消息,看来cffi无法安装。该库取决于操作系统软件包libffi,因此您只需要向libffi-dev安装的软件包中添加apk

我通过启动docker容器并手动安装失败的库来手动测试。通过docker run --rm -it python:3.7-alpine /bin/sh,然后通过pip install ...apk add ...