ldap-server/Dockerfile

53 lines
1.5 KiB
Docker
Raw Normal View History

2022-12-14 11:19:32 +01:00
FROM debian:stable-slim
ARG LDAP_ADMIN_PASSWORD
ARG LDAP_DOMAIN
ARG LDAP_ORGANISATION
2022-12-14 21:57:05 +01:00
ARG LDAP_USER
ARG LDAP_GROUP
2022-12-14 11:19:32 +01:00
ENV LDAP_ADMIN_PASSWORD $LDAP_ADMIN_PASSWORD
ENV LDAP_ORGANISATION $LDAP_ORGANISATION
ENV LDAP_DOMAIN $LDAP_DOMAIN
2022-12-14 21:57:05 +01:00
ENV LDAP_USER $LDAP_USER
ENV LDAP_GROUP $LDAP_GROUP
2022-12-14 11:19:32 +01:00
RUN apt-get update -y && apt dist-upgrade -y
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y slapd ldap-utils
2022-12-14 21:57:05 +01:00
RUN usermod -u ${LDAP_USER} openldap && \
groupmod -g ${LDAP_GROUP} openldap
2022-12-14 11:19:32 +01:00
ADD slapd.sh /opt/slapd
2022-12-14 21:57:05 +01:00
RUN /opt/slapd
2022-12-14 22:13:58 +01:00
COPY ./schema/*.ldif ./schema/*.schema /etc/ldap/schema/
2022-12-14 21:57:05 +01:00
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 && \
2022-12-14 22:13:58 +01:00
echo "dn: olcOverlay={0}lastbind, olcDatabase={1}mdb,cn=config\nobjectClass: olcLastBindConfig\nolcOverlay: {0}lastbind" | slapadd -n 0 && \
slapadd -l /etc/ldap/schema/nextcloud.ldif && \
2022-12-14 21:57:05 +01:00
rm /tmp/config.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/ && \
2022-12-14 22:13:58 +01:00
chmod -R o+rwx /var/lib/ldap && \
2022-12-14 21:57:05 +01:00
chmod -R o+rw /var/run/slapd/
2022-12-14 11:19:32 +01:00
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2022-12-14 21:57:05 +01:00
ADD entrypoint.sh /entrypoint.sh
#VOLUME ["/var/lib/ldap"]
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 389
CMD ["/usr/sbin/slapd","-h", "ldap:///","-d","4"]