0

I am trying to pip install python-ldap in Docker but am missing lber.h. I need python-ldap because I am trying to implement an OS agnostic SSO for my application, following this for now and hoping it doesn't break the rest of my app https://code.tutsplus.com/tutorials/flask-authentication-with-ldap--cms-23101

I have tried

RUN apk add libsasl2-dev libldap2-dev libssl-dev

and

RUN apk --no-cache add libsasl2-dev libldap2-dev libssl-dev

but I get the following error:

ERROR: unsatisfiable constraints:
  libldap2-dev (missing):
    required by: world[libldap2-dev]
  libsasl2-dev (missing):
    required by: world[libsasl2-dev]
  libssl-dev (missing):
    required by: world[libssl-dev]

Having gone to https://pkgs.alpinelinux.org/packages?name=libldap2-dev&branch=edge I feel that it is possible that these packages do indeed not exist within the alpine python image. Therefore, I tried substituting the installations with packages that exist in the above link, namely: openssl libsasl libldap This didn't work either and had the same effect as not installing any of the packages i.e. the header missing error appeared:

Modules/constants.h:7:10: fatal error: lber.h: No such file or directory

 #include "lber.h"
          ^~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

as a result of /tmp/pip-install-doifa8k9/python-ldap/

My Dockerfile:

    FROM python:3.8.0-alpine

    WORKDIR /home/flask
    ADD . /home/flask

    RUN apk --no-cache add --update --virtual .build-editdistance gcc g++ && \
        apk --no-cache add libsasl libldap openssl && \
        apk --no-cache add --update --virtual .libs libstdc++ && \
        apk add linux-headers && \
        apk add unixodbc-dev; 

    RUN rm -rf /var/cache/apk/* && \
        pip install --upgrade pip && \
        pip install --upgrade setuptools && \
        pip install --no-cache-dir -Ur requirements.txt && \
        apk del .build-editdistance;

    EXPOSE 5000
Jacob Porter
  • 91
  • 1
  • 7

1 Answers1

4

For alpine python in docker:

apk add openldap-dev

instead of

apk add libsasl libldap openssl

This is answered in I can't install python-ldap but the answer is buried sufficiently deep and obfuscated by the accepted answer ( which is where libsasl libldap openssl came from) that it would be a good idea to keep this docker specific question

Jacob Porter
  • 91
  • 1
  • 7