milan
milan

Reputation: 2417

error when installing from pipfile.lock in docker

I am trying to use docker in the project. It was working fine unless i used django channels and Pillow. Below was my working configuration

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"]

my pipfile is

[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 = "*"

the error i get is something like this

enter image description here

if i remove the pillow, channels and channels-redis from pipfile, it works. How do i solve this issue?

Upvotes: 2

Views: 1896

Answers (1)

bimsapi
bimsapi

Reputation: 5065

In my experience, errors like this are often the result of a transitive, native dependency that's missing. From the error message, it looks like cffi won't install. That library depends on an OS package libffi, so you should just need add libffi-dev to the packages installed by apk.

I tested this manually, by starting a docker container and installing the failed libs manually. Via docker run --rm -it python:3.7-alpine /bin/sh, then pip install ... or apk add ...

Upvotes: 1

Related Questions