Docker python3.8 alpine python-ldab安装失败缺少lber.h

Jac*_*ter 2 ldap python-3.x docker

我正在尝试在 Docker 中 pip install python-ldap 但缺少 lber.h。我需要 python-ldap 因为我正在尝试为我的应用程序实现一个与操作系统无关的 SSO,现在遵循此方法并希望它不会破坏我的应用程序的其余部分https://code.tutsplus.com/tutorials/flask-authentication -with-ldap--cms-23101

我努力了

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

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

但我收到以下错误:

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]
Run Code Online (Sandbox Code Playgroud)

访问https://pkgs.alpinelinux.org/packages?name=libldap2-dev&branch=edge我觉得这些包可能确实不存在于 alpine python 映像中。因此,我尝试用上述链接中存在的软件包替换安装,即: openssl libsasl libldap 这也不起作用,并且与不安装任何软件包具有相同的效果,即出现标头丢失错误:

Modules/constants.h:7:10: 致命错误: lber.h: 没有这样的文件或目录

 #include "lber.h"
          ^~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

后果/tmp/pip-install-doifa8k9/python-ldap/

我的 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
Run Code Online (Sandbox Code Playgroud)

Jac*_*ter 8

对于 docker 中的高山 python:

apk add openldap-dev
Run Code Online (Sandbox Code Playgroud)

代替

apk add libsasl libldap openssl
Run Code Online (Sandbox Code Playgroud)

这是我无法安装 python-ldap中的答案,但答案被埋得足够深,并被接受的答案(这是 libsasl libldap openssl 的来源)混淆了,最好保留这个 docker 特定问题