Skip to content

[BUG] libldap package not installed in web and postorious 0.5 image #703

@8Iue

Description

@8Iue

Tag/version of Container Images
Choose from: 0.5.0

Overview

It appears that the libldap package is not installed in the mailman-web:0.5 Docker image, despite being listed as a dependency in the Dockerfile for both web and postorious images.

The libldap dependency installation was added in this commit: 031c1ce

$ git clone https://github.com/maxking/docker-mailman.git                                                                                                
Cloning into 'docker-mailman'...                                                                                                                                                     
remote: Enumerating objects: 2694, done.                                                                                                                                             
remote: Counting objects: 100% (1006/1006), done.                                                                                                                                    
remote: Compressing objects: 100% (343/343), done.                                                                                                                                                                                                                                                                                                                         
remote: Total 2694 (delta 742), reused 865 (delta 657), pack-reused 1688                                                                                                             
Receiving objects: 100% (2694/2694), 1.14 MiB | 10.79 MiB/s, done.                                                                                                                   
Resolving deltas: 100% (1637/1637), done.                                                                                                                                            
blue@tuxtop: [10:14:17] /tmp$ cd docker-mailman/web
blue@tuxtop: [10:18:28] /tmp/docker-mailman/web$ curl -sSL https://github.com/docker/buildx/releases/download/v0.15.0/buildx-v0.15.0.linux-amd64 -o ~/.docker/cli-plugins/docker-buildx                                                                                                                                                                                    
blue@tuxtop: [10:20:05] /tmp/docker-mailman/web$ vim ~/.docker/cli-plugins/docker-buildx                                                                                             
blue@tuxtop: [10:20:09] /tmp/docker-mailman/web$ docker buildx version                                                                                                                                                                                                                                                                                                     
github.com/docker/buildx v0.15.0 d3a53189f7e9c917eeff851c895b9aad5a66b108                                                                                                            
blue@tuxtop: [10:20:12] /tmp/docker-mailman/web$ DOCKER_BUILDKIT=1 docker build -t mailman-web:local-0.5 .                                                                           
[+] Building 73.2s (14/14) FINISHED                                                                                                                                                                                                                                                                                                                         docker:default 
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                                                                                                                  0.0s 
 => => transferring dockerfile: 1.81kB                                                                                                                                                                                                                                                                                                                                0.0s 
 => [internal] load .dockerignore                                                                                                                                                                                                                                                                                                                                     0.0s 
 => => transferring context: 2B                                                                                                                                                                                                                                                                                                                                       0.0s 
 => resolve image config for docker.io/docker/dockerfile:1.3                                                                                                                                                                                                                                                                                                          1.8s 
 => docker-image://docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2                                                                                                                                                                                                                                            1.0s 
 => => resolve docker.io/docker/dockerfile:1.3@sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2                                                                                                                                                                                                                                                0.0s 
 => => sha256:42399d4635eddd7a9b8a24be879d2f9a930d0ed040a61324cfdf59ef1357b3b2 2.00kB / 2.00kB                                                                                                                                                                                                                                                                        0.0s 
 => => sha256:93f32bd6dd9004897fed4703191f48924975081860667932a4df35ba567d7426 528B / 528B                                                                                                                                                                                                                                                                            0.0s 
 => => sha256:e532695ddd93ca7c85a816c67afdb352e91052fab7ac19a675088f80915779a7 1.21kB / 1.21kB                                                                                                                                                                                                                                                                        0.0s 
 => => sha256:24a639a53085eb680e1d11618ac62f3977a3926fedf5b8471ace519b8c778030 9.67MB / 9.67MB                                                                                                                                                                                                                                                                        0.9s 
 => => extracting sha256:24a639a53085eb680e1d11618ac62f3977a3926fedf5b8471ace519b8c778030                                                                                                                                                                                                                                                                             0.1s 
 => [internal] load metadata for docker.io/library/alpine:3.20.0                                                                                                                                                                                                                                                                                                      0.0s 
 => [internal] load build context                                                                                                                                                                                                                                                                                                                                     0.0s 
 => => transferring context: 22.93kB                                                                                                                                                                                                                                                                                                                                  0.0s 
 => [stage-0 1/7] FROM docker.io/library/alpine:3.20.0                                                                                                                                                                                                                                                                                                                0.0s 
 => [stage-0 2/7] COPY requirements.txt /tmp/                                                                                                                                                                                                                                                                                                                         0.0s 
 => [stage-0 3/7] RUN --mount=type=cache,target=/root/.cache     set -ex  && apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers libldap            postgresql-dev mariadb-dev mariadb-connector-c python3-dev libffi-dev openldap-dev cargo rust  && apk add --no-cache --virtual .mailman-rundeps bash sassc tzdata     postgresql-client mysql-c  67.5s 
 => [stage-0 4/7] COPY mailman-web /opt/mailman-web                                                                                                                                                                                                                                                                                                                   0.0s 
 => [stage-0 5/7] COPY docker-entrypoint.sh /usr/local/bin/                                                                                                                                                                                                                                                                                                           0.0s 
 => [stage-0 6/7] RUN chown -R mailman /opt/mailman-web/  && chmod u+x /opt/mailman-web/manage.py                                                                                                                                                                                                                                                                     0.5s 
 => [stage-0 7/7] WORKDIR /opt/mailman-web                                                                                                                                                                                                                                                                                                                            0.1s 
 => exporting to image                                                                                                                                                                                                                                                                                                                                                2.1s 
 => => exporting layers                                                                                                                                                                                                                                                                                                                                               2.1s 
 => => writing image sha256:f467675b96d14abf9b4b7bcca6897b23166c8b088a31d3b5adf8b6f01a3da37a                                                                                                                                                                                                                                                                          0.0s 
 => => naming to docker.io/library/mailman-web:local-0.5

$ docker run --rm -it -e SECRET_KEY='test_secret_key' -e MAILMAN_HOSTNAME='localhost' mailman-web:local-0.5

/opt/mailman-web # apk list | grep ldap
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.20/main: No such file or directory
WARNING: opening from cache https://dl-cdn.alpinelinux.org/alpine/v3.20/community: No such file or directory
/opt/mailman-web # 

This issue seems to be happening because libldap is included in the .build-deps virtual package group, which is removed at the end of the build process, causing the package to be uninstalled.

[...]
  7 # Install packages and dependencies for postorius and hyperkitty Add user for
  8 # executing apps, change ownership for uwsgi+django files and set execution
  9 # rights for management script
 10 RUN --mount=type=cache,target=/root/.cache \
 11     set -ex \
 12   && apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers libldap \
 13            postgresql-dev mariadb-dev mariadb-connector-c python3-dev libffi-dev openldap-dev cargo rust \
[...]
 32   && apk del .build-deps \
[...]

The correct approach is to include libldap in the .mailman-rundeps group to make sure that it remains in the final image.

Steps to Reproduce:

  1. Pull the latest mailman-web:0.5 image:

    $ docker pull maxking/mailman-web:0.5
  2. Inspect the container image:

    $ docker container inspect mailman-web | grep Image
  3. Check if libldap is installed:

    $ docker container exec -t mailman-web /sbin/apk list | grep ldap

Findings:

The libldap package is not installed in the container. Upon manually installing libldap, it becomes clear that the package was missing initially.

Solution:

To resolve this issue, libldap should be included in the .mailman-rundeps virtual package group instead of .build-deps to ensure it remains installed in the final image. Here is the corrected portion of the Dockerfile:

RUN --mount=type=cache,target=/root/.cache \
    set -ex \
    && apk update \
-    && apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers libldap \
+    && apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers \
       postgresql-dev mariadb-dev mariadb-connector-c python3-dev libffi-dev openldap-dev cargo rust \
    && apk add --no-cache --virtual .mailman-rundeps bash sassc tzdata \
       postgresql-client mysql-client py3-mysqlclient curl mailcap gettext \
-      python3 py3-pip xapian-core xapian-bindings-python3 libffi pcre-dev py-cryptography \
+     python3 py3-pip xapian-core xapian-bindings-python3 libffi pcre-dev py-cryptography libldap \
    && python3 -m pip install --break-system-packages -U 'Django<4.3' pip setuptools wheel \
    && pip install --break-system-breakages -r /tmp/requirements.txt \
            whoosh \
            uwsgi \
            psycopg2 \
            dj-database-url \
            mysqlclient \
            typing \
            xapian-haystack \
            django-auth-ldap \
            pymemcache \
            diskcache \
            django-utils-six \
            tzdata \
            'django-allauth[socialaccount,openid]' \
    && apk del .build-deps \
    && addgroup -S mailman \
    && adduser -S -G mailman mailman

I'll create a PR to address this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions