Ldap Docker Server
This commit is contained in:
commit
9dde6c39b4
21
Dockerfile
Normal file
21
Dockerfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
FROM debian:stable-slim
|
||||||
|
|
||||||
|
ARG LDAP_ADMIN_PASSWORD
|
||||||
|
ARG LDAP_DOMAIN
|
||||||
|
ARG LDAP_ORGANISATION
|
||||||
|
|
||||||
|
ENV LDAP_ADMIN_PASSWORD $LDAP_ADMIN_PASSWORD
|
||||||
|
ENV LDAP_ORGANISATION $LDAP_ORGANISATION
|
||||||
|
ENV LDAP_DOMAIN $LDAP_DOMAIN
|
||||||
|
|
||||||
|
RUN apt-get update -y && apt dist-upgrade -y
|
||||||
|
|
||||||
|
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y slapd ldap-utils
|
||||||
|
|
||||||
|
EXPOSE 389
|
||||||
|
|
||||||
|
ADD slapd.sh /opt/slapd
|
||||||
|
|
||||||
|
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
|
CMD /opt/slapd
|
12
docker-compose.yml
Normal file
12
docker-compose.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
version: "2.4"
|
||||||
|
|
||||||
|
services:
|
||||||
|
ldap:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
args:
|
||||||
|
- LDAP_ADMIN_PASSWORD=${LDAP_ADMIN_PASSWORD}
|
||||||
|
- LDAP_ORGANISATION=${LDAP_ORGANISATION}
|
||||||
|
- LDAP_DOMAIN=${LDAP_DOMAIN}
|
||||||
|
|
3
env.sample
Normal file
3
env.sample
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
LDAP_ADMIN_PASSWORD=admin
|
||||||
|
LDAP_ORGANISATION=organisation
|
||||||
|
LDAP_DOMAIN=domain
|
42
slapd.sh
Executable file
42
slapd.sh
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
status () {
|
||||||
|
echo "---> ${@}" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
set -x
|
||||||
|
: LDAP_ADMIN_PASSWORD=${LDAP_ADMIN_PASSWORD}
|
||||||
|
: LDAP_DOMAIN=${LDAP_DOMAIN}
|
||||||
|
: LDAP_ORGANISATION=${LDAP_ORGANISATION}
|
||||||
|
|
||||||
|
if [ ! -e /var/lib/ldap/docker_bootstrapped ]; then
|
||||||
|
status "configuring slapd for first run"
|
||||||
|
|
||||||
|
cat <<EOF | debconf-set-selections
|
||||||
|
slapd slapd/internal/generated_adminpw password ${LDAP_ADMIN_PASSWORD}
|
||||||
|
slapd slapd/internal/adminpw password ${LDAP_ADMIN_PASSWORD}
|
||||||
|
slapd slapd/password2 password ${LDAP_ADMIN_PASSWORD}
|
||||||
|
slapd slapd/password1 password ${LDAP_ADMIN_PASSWORD}
|
||||||
|
slapd slapd/dump_database_destdir string /var/backups/slapd-VERSION
|
||||||
|
slapd slapd/domain string ${LDAP_DOMAIN}
|
||||||
|
slapd shared/organization string ${LDAP_ORGANISATION}
|
||||||
|
slapd slapd/backend string HDB
|
||||||
|
slapd slapd/purge_database boolean true
|
||||||
|
slapd slapd/move_old_database boolean true
|
||||||
|
slapd slapd/allow_ldap_v2 boolean false
|
||||||
|
slapd slapd/no_configuration boolean false
|
||||||
|
slapd slapd/dump_database select when needed
|
||||||
|
EOF
|
||||||
|
|
||||||
|
dpkg-reconfigure -f noninteractive slapd
|
||||||
|
|
||||||
|
touch /var/lib/ldap/docker_bootstrapped
|
||||||
|
else
|
||||||
|
status "found already-configured slapd"
|
||||||
|
fi
|
||||||
|
|
||||||
|
status "starting slapd"
|
||||||
|
set -x
|
||||||
|
exec /usr/sbin/slapd -h "ldap:///" -u openldap -g openldap -d 0
|
Loading…
Reference in New Issue
Block a user