FROM debian:stable-slim ARG LDAP_ADMIN_PASSWORD ARG LDAP_DOMAIN ARG LDAP_ORGANISATION ARG LDAP_USER ARG LDAP_GROUP ENV LDAP_ADMIN_PASSWORD $LDAP_ADMIN_PASSWORD ENV LDAP_ORGANISATION $LDAP_ORGANISATION ENV LDAP_DOMAIN $LDAP_DOMAIN ENV LDAP_USER $LDAP_USER ENV LDAP_GROUP $LDAP_GROUP RUN apt-get update -y && apt dist-upgrade -y RUN DEBIAN_FRONTEND=noninteractive apt-get install -y slapd ldap-utils RUN usermod -u ${LDAP_USER} openldap && \ groupmod -g ${LDAP_GROUP} openldap ADD slapd.sh /opt/slapd RUN /opt/slapd RUN slapcat -n 0 \ |sed 's/cn: config/cn: config\nolcPasswordHash: {CRYPT}\nolcPasswordCryptSaltFormat: $6$%.16s/' \ |sed 's/cn: module{0}/cn: module{0}\nolcModuleLoad: {0}lastbind/' > /tmp/config.ldif && \ rm -rf /etc/ldap/slapd.d/* && \ slapadd -n 0 -F /etc/ldap/slapd.d/ -l /tmp/config.ldif && \ rm /tmp/config.ldif RUN echo "dn: olcOverlay={0}lastbind, olcDatabase={1}mdb,cn=config\nobjectClass: olcLastBindConfig\nolcOverlay: {0}lastbind" \ | slapadd -n 0 COPY ./schema/*.ldif ./schema/*.schema /etc/ldap/schema/ RUN slapadd -l /etc/ldap/schema/nextcloud.ldif RUN chmod -R o+rw /etc/ldap/slapd.d/ && \ chmod -R o+rwx /etc/ldap/slapd.d/cn=config/ && \ chmod -R o+rwx /etc/ldap/slapd.d/cn=config/cn=schema/ && \ chmod -R o+rw /var/run/slapd/ RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* ADD entrypoint.sh /entrypoint.sh #VOLUME ["/var/lib/ldap"] ENTRYPOINT ["/entrypoint.sh"] EXPOSE 389 CMD ["/usr/sbin/slapd","-h", "ldap:///","-d","4"]