Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Base Image
FROM debian:stable-slim
LABEL org.opencontainers.image.authors="Worteks" \
name="openldap-ltb"

# Install required binaries
RUN export DEBIAN_FRONTEND=noninteractive && \
apt update && \
apt upgrade --no-install-recommends -y && \
apt install --no-install-recommends -y curl && \
apt install --no-install-recommends -y gpg && \
apt install --no-install-recommends -y ca-certificates && \
apt install --no-install-recommends -y wget

# Openldap-ltb GPG and Repostiory
RUN curl https://ltb-project.org/documentation/_static/RPM-GPG-KEY-LTB-project | gpg --dearmor > /usr/share/keyrings/ltb-project-openldap-archive-keyring.gpg
RUN echo "deb [arch=amd64 signed-by=/usr/share/keyrings/ltb-project-openldap-archive-keyring.gpg] https://ltb-project.org/debian/openldap26/bookworm bookworm main" > /etc/apt/sources.list.d/ltb-project.list
RUN apt update

# Installing Openldap-ltb
RUN apt install --no-install-recommends -y openldap-ltb && \
apt install --no-install-recommends -y openldap-ltb-contrib-overlays && \
apt install --no-install-recommends -y openldap-ltb-mdb-utils && \
apt install --no-install-recommends -y openldap-ltb-explockout && \
apt install --no-install-recommends -y ldapvi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slapd-cli is included in Debian packages, you don't have to install it

# permissions
RUN chmod +x /usr/local/openldap/sbin/slapd-cli
RUN chmod 600 /usr/local/openldap/etc/openldap/slapd-cli.conf
RUN chmod 600 /usr/local/openldap/etc/openldap/lload.conf

# add to $PATH
ENV PATH=/usr/local/openldap/bin:/usr/local/openldap/sbin:$PATH
ENV SLAPD_CONF_DIR=/usr/local/openldap/etc/openldap/slapd.d/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it needed?


# add slapd customisation
RUN sed "s/SLAPD_CONF_DIR=\"\"/SLAPD_CONF_DIR=\"\$SLAPD_PATH\/etc\/openldap\/slapd.d\"/g" -i /usr/local/openldap/etc/openldap/slapd-cli.conf

# Set working directory
WORKDIR /usr/local/openldap

# Clean up
RUN echo "# Clean up image" && \
rm -rf /tmp/* && \
apt clean && \
apt autoremove --yes && \
rm -rf /var/lib/{apt,dpkg,cache,log}/

# Mount locations
VOLUME /usr/local/openldap/etc/openldap/slapd.d
VOLUME /usr/local/openldap/var/openldap-data

COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
# openldap-docker
Docker image for OpenLDAP LTB

## Build the image locally
```
docker buildx build -t openldap-ltb .
```

## Deploy the container
```
docker compose up -d
```

## Check the container status and logs
```
docker ps -a
docker logs -f openldap-ltb
```

## Community images
https://hub.docker.com/u/ltbproject/openldap-ltb
10 changes: 10 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
openldap-ltb:
image: openldap-ltb
container_name: openldap-ltb
ports:
- '389:389'
- '636:636'
volumes:
- ./openldap-ltb/schema:/usr/local/openldap/etc/openldap/slapd.d
- ./openldap-ltb/data:/usr/local/openldap/var/openldap-data
14 changes: 14 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# permission issue
chmod 777 /usr/local/openldap/etc/openldap/slapd.d /usr/local/openldap/var/openldap-data

# import config and data
slapd-cli importldifconfigtemplate
slapd-cli importdatatemplate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break existing conf and data


# start process
slapd-cli debug start

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be run in foreground, either with slapd-cli debug, either with slapd command line

# tail /dev/null
tail -f /dev/null