Skip to content

Commit 1d7c633

Browse files
committed
Added seeding from internal path.
1 parent 2a03b39 commit 1d7c633

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
.DS_Store
12
!/.git*
23
/VOLUMES

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Latest release: 1.3.0 - OpenLDAP 2.4.48 - [Changelog](CHANGELOG.md) | [Docker H
1919
- [Data persistence](#data-persistence)
2020
- [Edit your server configuration](#edit-your-server-configuration)
2121
- [Seed ldap database with ldif](#seed-ldap-database-with-ldif)
22+
- [Seed from internal path](#seed-from-internal-path)
2223
- [Use an existing ldap database](#use-an-existing-ldap-database)
2324
- [Backup](#backup)
2425
- [Administrate your ldap server](#administrate-your-ldap-server)
@@ -156,6 +157,24 @@ argument to entrypoint if you don't want to overwrite them.
156157
--volume ./ldif:/container/service/slapd/assets/config/bootstrap/ldif/custom \
157158
osixia/openldap:1.3.0 --copy-service
158159

160+
#### Seed from internal path
161+
162+
This image can load ldif and schema files at startup from an internal path. This is useful if a continuous integration service mounts automatically the working copy (sources) into a docker service, which has a relation to the ci job.
163+
164+
For example: Gitlab is not capable of mounting custom paths into docker services of a ci job, but gitlab automatically mounts the working copy in every service container. So the working copy (sources) are accessible under `/builds` in every services
165+
of a ci job. The path to the working copy can be obtained via `${CI_PROJECT_DIR}`. See also: https://docs.gitlab.com/runner/executors/docker.html#build-directory-in-service
166+
167+
This may also work with other CI services, if they automatically mount the working directory to the services of a ci job like gitlab ci does.
168+
169+
In order to seed ldif or schema files from internal path you must set the specific environment variable `LDAP_SEED_INTERNAL_LDIF_PATH` and/or `LDAP_SEED_INTERNAL_SCHEMA_PATH`. If set this will copy any *.ldif or *.schema file into the default seeding
170+
directories of this image.
171+
172+
Example variables defined in gitlab-ci.yml:
173+
174+
variables:
175+
LDAP_SEED_INTERNAL_LDIF_PATH: "${CI_PROJECT_DIR}/docker/openldap/ldif"
176+
LDAP_SEED_INTERNAL_SCHEMA_PATH: "${CI_PROJECT_DIR}/docker/openldap/schema"
177+
159178
### Use an existing ldap database
160179

161180
This can be achieved by mounting host directories as volume.

image/environment/default.startup.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,7 @@ LDAP_REMOVE_CONFIG_AFTER_SETUP: true
6161
LDAP_SSL_HELPER_PREFIX: ldap # ssl-helper first search config from LDAP_SSL_HELPER_* variables, before SSL_HELPER_* variables.
6262

6363
SSL_HELPER_AUTO_RENEW_SERVICES_IMPACTED: slapd
64+
65+
# Internal seeding. For example, for services in Gitlab CI.
66+
LDAP_SEED_INTERNAL_LDIF_PATH:
67+
LDAP_SEED_INTERNAL_SCHEMA_PATH:

image/service/slapd/startup.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ file_env 'LDAP_ADMIN_PASSWORD'
3838
file_env 'LDAP_CONFIG_PASSWORD'
3939
file_env 'LDAP_READONLY_USER_PASSWORD'
4040

41+
# Seed ldif from internal path if specified
42+
file_env 'LDAP_SEED_INTERNAL_LDIF_PATH'
43+
if [ ! -z "${LDAP_SEED_INTERNAL_LDIF_PATH}" ]; then
44+
mkdir -p /container/service/slapd/assets/config/bootstrap/ldif/custom/
45+
cp -R ${LDAP_SEED_INTERNAL_LDIF_PATH}/*.ldif /container/service/slapd/assets/config/bootstrap/ldif/custom/
46+
fi
47+
48+
# Seed schema from internal path if specified
49+
file_env 'LDAP_SEED_INTERNAL_SCHEMA_PATH'
50+
if [ ! -z "${LDAP_SEED_INTERNAL_SCHEMA_PATH}" ]; then
51+
mkdir -p /container/service/slapd/assets/config/bootstrap/schema/custom/
52+
cp -R ${LDAP_SEED_INTERNAL_SCHEMA_PATH}/*.schema /container/service/slapd/assets/config/bootstrap/schema/custom/
53+
fi
54+
4155
# create dir if they not already exists
4256
[ -d /var/lib/ldap ] || mkdir -p /var/lib/ldap
4357
[ -d /etc/ldap/slapd.d ] || mkdir -p /etc/ldap/slapd.d

0 commit comments

Comments
 (0)