# Local OpenLDAP for development and tests only. Not for production.
#
# Alpine 3.24 ships OpenLDAP 2.6.15. No sshd is installed here; the
# "openssh-lpk" bit below is only an LDAP schema for the ldapPublicKey
# objectClass that the app writes.
FROM alpine:3.24

RUN apk add --no-cache \
        openldap \
        openldap-back-mdb \
        openldap-clients \
    && mkdir -p /run/openldap /var/lib/openldap/openldap-data /etc/openldap/slapd.d \
    && rm -rf /etc/openldap/slapd.conf /etc/openldap/slapd.ldif

COPY config.ldif openssh-lpk.ldif seed.ldif /bootstrap/
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

EXPOSE 389
HEALTHCHECK --interval=5s --timeout=3s --retries=10 \
    CMD ldapsearch -x -H ldap://localhost -b "" -s base namingContexts | grep -q "dc=ungleich,dc=ch" || exit 1

ENTRYPOINT ["/entrypoint.sh"]
