Update: Dockerfile && Move configuration to entrypoint

This commit is contained in:
Siroco 2023-05-17 13:09:18 -05:00
parent e37dc23961
commit 1fed83f3c0
No known key found for this signature in database
GPG Key ID: 1324098302A514B0
5 changed files with 69 additions and 32 deletions

View File

@ -1,11 +1,20 @@
FROM debian:stable-slim
ARG LDAP_ADMIN_PASSWORD
ARG LDAP_DOMAIN
ARG LDAP_ORGANISATION
ARG LDAP_USER
ARG LDAP_GROUP
FROM debian:stable-slim
ARG LDAP_ADMIN_PASSWORD
ARG LDAP_DOMAIN
ARG LDAP_ORGANISATION
ARG LDAP_USER=1000
ARG LDAP_GROUP=1000
ARG UID=1000
ARG GID=1000
ENV LDAP_ADMIN_PASSWORD $LDAP_ADMIN_PASSWORD
ENV LDAP_ORGANISATION $LDAP_ORGANISATION
ENV LDAP_DOMAIN $LDAP_DOMAIN
@ -14,24 +23,26 @@ 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 DEBIAN_FRONTEND=noninteractive apt-get install -y slapd ldap-utils ca-certificates
RUN usermod -u ${LDAP_USER} openldap && \
groupmod -g ${LDAP_GROUP} openldap
RUN usermod -u ${UID} openldap && \
groupmod -g ${GID} openldap
ADD slapd.sh /opt/slapd
RUN /opt/slapd
COPY ./schema/*.ldif ./schema/*.schema /etc/ldap/schema/
## Run on entrypoint
#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 && \
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 && \
rm /tmp/config.ldif
#COPY ./schema/*.ldif ./schema/*.schema /etc/ldap/schema/
#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 && \
# 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 && \
# rm /tmp/config.ldif
RUN chmod -R o+rw /etc/ldap/slapd.d/ && \
chmod -R o+rwx /etc/ldap/slapd.d/cn=config/ && \

View File

@ -5,24 +5,14 @@ volumes:
services:
admin:
image: registry.audio-lab.org/ldapphpadmin
restart: always
links:
- ldap
ports:
- ${LDAP_ADMIN_PORT}:80
build:
context: phpldapadmin
dockerfile: Dockerfile
args:
- LDAP_BASE=${LDAP_BASE}
ldap:
user: ${USER_GROUP}
image: registry.audio-lab.org/ldap
restart: always
ports:
- ${LDAP_PORT}:389
volumes:
- data:/var/lib/ldap
build:
context: .
dockerfile: Dockerfile
@ -32,7 +22,3 @@ services:
- LDAP_DOMAIN=${LDAP_DOMAIN}
- LDAP_USER=${LDAP_USER}
- LDAP_GROUP=${LDAP_GROUP}
environment:
- LDAP_ADMIN_PASSWORD=${LDAP_ADMIN_PASSWORD}
- LDAP_ORGANISATION=${LDAP_ORGANISATION}
- LDAP_DOMAIN=${LDAP_DOMAIN}

View File

@ -0,0 +1,38 @@
version: "2.4"
volumes:
data:
services:
admin:
image: registry.audio-lab.org/ldapphpadmin
restart: always
links:
- ldap
ports:
- ${LDAP_ADMIN_PORT}:80
build:
context: phpldapadmin
dockerfile: Dockerfile
args:
- LDAP_BASE=${LDAP_BASE}
ldap:
user: ${USER_GROUP}
image: registry.audio-lab.org/ldap
restart: always
ports:
- ${LDAP_PORT}:389
volumes:
- data:/var/lib/ldap
build:
context: .
dockerfile: Dockerfile
args:
- LDAP_ADMIN_PASSWORD=${LDAP_ADMIN_PASSWORD}
- LDAP_ORGANISATION=${LDAP_ORGANISATION}
- LDAP_DOMAIN=${LDAP_DOMAIN}
- LDAP_USER=${LDAP_USER}
- LDAP_GROUP=${LDAP_GROUP}
environment:
- LDAP_ADMIN_PASSWORD=${LDAP_ADMIN_PASSWORD}
- LDAP_ORGANISATION=${LDAP_ORGANISATION}
- LDAP_DOMAIN=${LDAP_DOMAIN}

View File

@ -2,6 +2,8 @@
set -x
RUN slapadd -n 0 -l /etc/ldap/schema/domain.ldif
/opt/slapd
slapadd -n 0 -l /etc/ldap/schema/domain.ldif
exec $@

View File

@ -16,8 +16,8 @@ slapd slapd/internal/adminpw password ${LDAP_ADMIN_PASSWORD}
slapd slapd/password2 password ${LDAP_ADMIN_PASSWORD}
slapd slapd/password1 password ${LDAP_ADMIN_PASSWORD}
slapd slapd/dump_database_destdir string /var/backups/slapd-VERSION
slapd slapd/domain string ${LDAP_DOMAIN}
slapd shared/organization string ${LDAP_ORGANISATION}
slapd slapd/domain string "${LDAP_DOMAIN}"
slapd shared/organization string "${LDAP_ORGANISATION}"
slapd slapd/backend string HDB
slapd slapd/purge_database boolean true
slapd slapd/move_old_database boolean true