diff --git a/Dockerfile b/Dockerfile index 92def5b..d62e624 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,16 @@ -FROM phusion/baseimage:0.9.8 -MAINTAINER Nick Stenning +FROM osixia-baseimage +MAINTAINER Bertrand Gouny -ENV HOME /root +# From Nick Stenning's work +# https://github.com/nickstenning/docker-slapd + +# Default configuration: can be overridden at the docker command line +ENV LDAP_ADMIN_PWD toor +ENV LDAP_ORGANISATION Example Inc. +ENV LDAP_DOMAIN example.com + +# /!\ To store the data outside the container, mount /var/lib/ldap as a data volume +# add -v /some/host/directory:/var/lib/ldap to the run command # Disable SSH RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh @@ -9,25 +18,25 @@ RUN rm -rf /etc/service/sshd /etc/my_init.d/00_regen_ssh_host_keys.sh # Use baseimage-docker's init system. CMD ["/sbin/my_init"] -# Configure apt -RUN echo 'deb http://us.archive.ubuntu.com/ubuntu/ precise universe' >> /etc/apt/sources.list +# Resynchronize the package index files from their sources RUN apt-get -y update -# Install slapd -RUN LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y slapd - -# Default configuration: can be overridden at the docker command line -ENV LDAP_ROOTPASS toor -ENV LDAP_ORGANISATION Acme Widgets Inc. -ENV LDAP_DOMAIN example.com +# Install openldap (slapd) and ldap-utils +RUN LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y slapd ldap-utils openssl +# Expose ldap default port EXPOSE 389 +# Create TSL certificats directory +RUN mkdir /etc/ldap/ssl + +# Add config directory +RUN mkdir /etc/ldap/config +ADD config /etc/ldap/config + +# Add slapd deamon RUN mkdir /etc/service/slapd ADD slapd.sh /etc/service/slapd/run -# To store the data outside the container, mount /var/lib/ldap as a data volume - +# Clear out the local repository of retrieved package files RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* - -# vim:ts=8:noet: diff --git a/config/auto/tls.ldif b/config/auto/tls.ldif new file mode 100644 index 0000000..55fb4ef --- /dev/null +++ b/config/auto/tls.ldif @@ -0,0 +1,17 @@ +dn: cn=config +changetype: modify +replace: olcTLSCACertificateFile +olcTLSCACertificateFile: /etc/ldap/ssl/ca.crt +- +replace: olcTLSCertificateFile +olcTLSCertificateFile: /etc/ldap/ssl/ldap.crt +- +replace: olcTLSCertificateKeyFile +olcTLSCertificateKeyFile: /etc/ldap/ssl/ldap.key +- +replace: olcTLSDHParamFile +olcTLSDHParamFile: /etc/ldap/ssl/dhparam.pem +- +replace: olcTLSVerifyClient +olcTLSVerifyClient: never + diff --git a/config/logging.ldif b/config/logging.ldif new file mode 100644 index 0000000..5494c10 --- /dev/null +++ b/config/logging.ldif @@ -0,0 +1,4 @@ +dn: cn=config +changetype: modify +replace: olcLogLevel +olcLogLevel: stats diff --git a/slapd.sh b/slapd.sh index cb75656..4c2fce3 100755 --- a/slapd.sh +++ b/slapd.sh @@ -7,18 +7,19 @@ status () { } set -x -: LDAP_ROOTPASS=${LDAP_ROOTPASS} +: LDAP_ADMIN_PWD=${LDAP_ADMIN_PWD} : LDAP_DOMAIN=${LDAP_DOMAIN} : LDAP_ORGANISATION=${LDAP_ORGANISATION} +############ Base config ############ if [ ! -e /var/lib/ldap/docker_bootstrapped ]; then status "configuring slapd for first run" cat <> /etc/dhosts + +fi + +# Replication +# todo + +# Other config files +for f in $(find /etc/ldap/config -maxdepth 1 -name \*.ldif -type f); do + status "Processing file ${f}" + ldapmodify -Y EXTERNAL -H ldapi:/// -f $f +done + +pkill slapd + +status "starting slapd on default port 389" set -x -exec /usr/sbin/slapd -h "ldap:///" -u openldap -g openldap -d 0 +exec /usr/sbin/slapd -h "ldap:///" -u openldap -g openldap -d -1