FROM alpine:3.7

ENV LDAPTLS_REQCERT=never

RUN apk add --no-cache \
    openldap \
    openldap-back-mdb \
    openldap-overlay-refint openldap-overlay-memberof \
    openldap-clients

COPY slapd.conf /etc/openldap/slapd.conf
COPY key.pem    /var/slapd/key.pem
COPY cert.pem   /var/slapd/cert.pem

RUN chown -R ldap:ldap /var/slapd /etc/openldap

EXPOSE 389
ENTRYPOINT ["/usr/sbin/slapd",\
            "-u","ldap","-g","ldap",\
            "-f","/etc/openldap/slapd.conf",\
            "-d","1",\
            "-h","ldap://"]