Skip to content

Commit

Permalink
Merge branch 'hotfix-1.1.9' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandGouny committed Jul 19, 2017
2 parents 1bc98e6 + 5b560b2 commit aee8721
Show file tree
Hide file tree
Showing 19 changed files with 929 additions and 251 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.1.9
Add :
- LDAP_RFC2307BIS_SCHEMA option to use rfc2307bis schema instead of nis default schema
- KEEP_EXISTING_CONFIG option to not change the ldap config

Update to light-baseimage:1.1.0 (debian stretch)

## 1.1.8
Fix :
- LDAP_ENFORCE_TLS is not working correctly #107
Expand Down
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
NAME = osixia/openldap
VERSION = 1.1.8
VERSION = 1.1.9

.PHONY: all build build-nocache test tag_latest release

all: build
.PHONY: build build-nocache test tag-latest push push-latest release git-tag-version

build:
docker build -t $(NAME):$(VERSION) --rm image
Expand All @@ -14,10 +12,17 @@ build-nocache:
test:
env NAME=$(NAME) VERSION=$(VERSION) bats test/test.bats

tag_latest:
tag-latest:
docker tag $(NAME):$(VERSION) $(NAME):latest

release: build test tag_latest
@if ! docker images $(NAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make build'"; false; fi
docker push $(NAME)
@echo "*** Don't forget to run 'twgit release/hotfix finish' :)"
push:
docker push $(NAME):$(VERSION)

push-latest:
docker push $(NAME):latest

release: build test tag-latest push push-latest

git-tag-version: release
git tag -a v$(VERSION) -m "v$(VERSION)"
git push origin v$(VERSION)
75 changes: 51 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
![Docker Stars](https://img.shields.io/docker/stars/osixia/openldap.svg)
![](https://images.microbadger.com/badges/image/osixia/openldap.svg)

Latest release: 1.1.8 - OpenLDAP 2.4.40 -  [Changelog](CHANGELOG.md) | [Docker Hub](https://hub.docker.com/r/osixia/openldap/) 
Latest release: 1.1.9 - OpenLDAP 2.4.44 - [Changelog](CHANGELOG.md) | [Docker Hub](https://hub.docker.com/r/osixia/openldap/) 

**A docker image to run OpenLDAP.**

Note:
- In the release 1.1.6 files `*.yaml.startup` have been renamed to `*.startup.yaml`
- Due to issues #44 and #73 versions before 1.1.6 are not considered as stable and tags will be removed from docker hub.

> OpenLDAP website : [www.openldap.org](http://www.openldap.org/)
- [Contributing](#contributing)
Expand All @@ -38,7 +34,7 @@ Note:
- [Link environment file](#link-environment-file)
- [Make your own image or extend this image](#make-your-own-image-or-extend-this-image)
- [Advanced User Guide](#advanced-user-guide)
- [Extend osixia/openldap:1.1.8 image](#extend-osixiaopenldap118-image)
- [Extend osixia/openldap:1.1.9 image](#extend-osixiaopenldap119-image)
- [Make your own openldap image](#make-your-own-openldap-image)
- [Tests](#tests)
- [Kubernetes](#kubernetes)
Expand All @@ -56,7 +52,7 @@ If you find this image useful here's how you can help:
## Quick Start
Run OpenLDAP docker image:

docker run --name my-openldap-container --detach osixia/openldap:1.1.8
docker run --name my-openldap-container --detach osixia/openldap:1.1.9

This start a new container with OpenLDAP running inside. Let's make the first search in our LDAP container:

Expand Down Expand Up @@ -92,7 +88,7 @@ It will create an empty ldap for the company **Example Inc.** and the domain **e
By default the admin has the password **admin**. All those default settings can be changed at the docker command line, for example:

docker run --env LDAP_ORGANISATION="My Company" --env LDAP_DOMAIN="my-company.com" \
--env LDAP_ADMIN_PASSWORD="JonSn0w" --detach osixia/openldap:1.1.8
--env LDAP_ADMIN_PASSWORD="JonSn0w" --detach osixia/openldap:1.1.9

#### Data persistence

Expand All @@ -108,6 +104,31 @@ For more information about docker data volume, please refer to:

Do not edit slapd.conf it's not used. To modify your server configuration use ldap utils: **ldapmodify / ldapadd / ldapdelete**

#### Seed ldap database with ldif

This image can load ldif files at startup with either `ldapadd` or `ldapmodify`.
Mount `.ldif` in `/container/service/slapd/assets/config/bootstrap/ldif` directory if you want to overwrite image default boostrap ldif files or in `/container/service/slapd/assets/config/bootstrap/ldif/custom` (recommended) to extend image config.

Files containing `changeType:` attributes will be loaded with `ldapmodify`.

The startup script provide some substitution in bootstrap ldif files:
`{{LDAP_BASE_DN }}` and `{{ LDAP_BACKEND }}` values are supported. Other `{{ * }}`
substitution are left as is.

Since startup script modifies `ldif` files, you **must** add `--copy-service`
argument to entrypoint if you don't want to overwrite them.


# single file example:
docker run \
--volume ./bootstrap.ldif:/container/service/slapd/assets/config/bootstrap/ldif/50-bootstrap.ldif \
osixia/openldap:1.1.9 --copy-service

#directory example:
docker run \
--volume ./lidf:/container/service/slapd/assets/config/bootstrap/ldif/custom \
osixia/openldap:1.1.9 --copy-service

### Use an existing ldap database

This can be achieved by mounting host directories as volume.
Expand All @@ -117,7 +138,7 @@ simply mount this directories as a volume to `/var/lib/ldap` and `/etc/ldap/slap

docker run --volume /data/slapd/database:/var/lib/ldap \
--volume /data/slapd/config:/etc/ldap/slapd.d
--detach osixia/openldap:1.1.8
--detach osixia/openldap:1.1.9

You can also use data volume containers. Please refer to:
> [https://docs.docker.com/engine/tutorials/dockervolumes/](https://docs.docker.com/engine/tutorials/dockervolumes/)
Expand All @@ -137,7 +158,7 @@ If you are looking for a simple solution to administrate your ldap server you ca
#### Use auto-generated certificate
By default, TLS is already configured and enabled, certificate is created using container hostname (it can be set by docker run --hostname option eg: ldap.example.org).

docker run --hostname ldap.my-company.com --detach osixia/openldap:1.1.8
docker run --hostname ldap.my-company.com --detach osixia/openldap:1.1.9

#### Use your own certificate

Expand All @@ -147,24 +168,24 @@ You can set your custom certificate at run time, by mounting a directory contain
--env LDAP_TLS_CRT_FILENAME=my-ldap.crt \
--env LDAP_TLS_KEY_FILENAME=my-ldap.key \
--env LDAP_TLS_CA_CRT_FILENAME=the-ca.crt \
--detach osixia/openldap:1.1.8
--detach osixia/openldap:1.1.9

Other solutions are available please refer to the [Advanced User Guide](#advanced-user-guide)

#### Disable TLS
Add --env LDAP_TLS=false to the run command:

docker run --env LDAP_TLS=false --detach osixia/openldap:1.1.8
docker run --env LDAP_TLS=false --detach osixia/openldap:1.1.9

### Multi master replication
Quick example, with the default config.

#Create the first ldap server, save the container id in LDAP_CID and get its IP:
LDAP_CID=$(docker run --hostname ldap.example.org --env LDAP_REPLICATION=true --detach osixia/openldap:1.1.8)
LDAP_CID=$(docker run --hostname ldap.example.org --env LDAP_REPLICATION=true --detach osixia/openldap:1.1.9)
LDAP_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $LDAP_CID)

#Create the second ldap server, save the container id in LDAP2_CID and get its IP:
LDAP2_CID=$(docker run --hostname ldap2.example.org --env LDAP_REPLICATION=true --detach osixia/openldap:1.1.8)
LDAP2_CID=$(docker run --hostname ldap2.example.org --env LDAP_REPLICATION=true --detach osixia/openldap:1.1.9)
LDAP2_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $LDAP2_CID)

#Add the pair "ip hostname" to /etc/hosts on each containers,
Expand Down Expand Up @@ -200,7 +221,7 @@ You may have some problems with mounted files on some systems. The startup scrip

To fix that run the container with `--copy-service` argument :

docker run [your options] osixia/openldap:1.1.8 --copy-service
docker run [your options] osixia/openldap:1.1.9 --copy-service

### Debug

Expand All @@ -209,11 +230,11 @@ Available levels are: `none`, `error`, `warning`, `info`, `debug` and `trace`.

Example command to run the container in `debug` mode:

docker run --detach osixia/openldap:1.1.8 --loglevel debug
docker run --detach osixia/openldap:1.1.9 --loglevel debug

See all command line options:

docker run osixia/openldap:1.1.8 --help
docker run osixia/openldap:1.1.9 --help


## Environment Variables
Expand Down Expand Up @@ -245,6 +266,8 @@ Required and used for new ldap server only:
- **LDAP_READONLY_USER_USERNAME** Read only user username. Defaults to `readonly`
- **LDAP_READONLY_USER_PASSWORD** Read only user password. Defaults to `readonly`

- **LDAP_RFC2307BIS_SCHEMA** Use rfc2307bis schema instead of nis schema. Defaults to `false`

Backend:
- **LDAP_BACKEND**: Ldap backend. Defaults to `hdb` (In comming versions v1.2.x default will be mdb)

Expand Down Expand Up @@ -276,11 +299,15 @@ Replication options:

If you want to set this variable at docker run command add the tag `#PYTHON2BASH:` and convert the yaml in python:

docker run --env LDAP_REPLICATION_HOSTS="#PYTHON2BASH:['ldap://ldap.example.org','ldap://ldap2.example.org']" --detach osixia/openldap:1.1.8
docker run --env LDAP_REPLICATION_HOSTS="#PYTHON2BASH:['ldap://ldap.example.org','ldap://ldap2.example.org']" --detach osixia/openldap:1.1.9

To convert yaml to python online: http://yaml-online-parser.appspot.com/

Other environment variables:
- **KEEP_EXISTING_CONFIG**: Do not change the ldap config. Defaults to `false`
- if set to *true* with an existing database, config will remain unchanged. Image tls and replication config will not be run. The container can be started with LDAP_ADMIN_PASSWORD and LDAP_CONFIG_PASSWORD empty or filled with fake data.
- if set to *true* when bootstrapping a new database, bootstap ldif and schema will not be added and tls and replication config will not be run.

- **LDAP_REMOVE_CONFIG_AFTER_SETUP**: delete config folder after setup. Defaults to `true`
- **LDAP_SSL_HELPER_PREFIX**: ssl-helper environment variables prefix. Defaults to `ldap`, ssl-helper first search config from LDAP_SSL_HELPER_* variables, before SSL_HELPER_* variables.

Expand All @@ -291,7 +318,7 @@ Other environment variables:
Environment variables can be set by adding the --env argument in the command line, for example:

docker run --env LDAP_ORGANISATION="My company" --env LDAP_DOMAIN="my-company.com" \
--env LDAP_ADMIN_PASSWORD="JonSn0w" --detach osixia/openldap:1.1.8
--env LDAP_ADMIN_PASSWORD="JonSn0w" --detach osixia/openldap:1.1.9

Be aware that environment variable added in command line will be available at any time
in the container. In this example if someone manage to open a terminal in this container
Expand All @@ -302,28 +329,28 @@ he will be able to read the admin password in clear text from environment variab
For example if your environment files **my-env.yaml** and **my-env.startup.yaml** are in /data/ldap/environment

docker run --volume /data/ldap/environment:/container/environment/01-custom \
--detach osixia/openldap:1.1.8
--detach osixia/openldap:1.1.9

Take care to link your environment files folder to `/container/environment/XX-somedir` (with XX < 99 so they will be processed before default environment files) and not directly to `/container/environment` because this directory contains predefined baseimage environment files to fix container environment (INITRD, LANG, LANGUAGE and LC_CTYPE).

Note: the container will try to delete the **\*.startup.yaml** file after the end of startup files so the file will also be deleted on the docker host. To prevent that : use --volume /data/ldap/environment:/container/environment/01-custom**:ro** or set all variables in **\*.yaml** file and don't use **\*.startup.yaml**:

docker run --volume /data/ldap/environment/my-env.yaml:/container/environment/01-custom/env.yaml \
--detach osixia/openldap:1.1.8
--detach osixia/openldap:1.1.9

#### Make your own image or extend this image

This is the best solution if you have a private registry. Please refer to the [Advanced User Guide](#advanced-user-guide) just below.

## Advanced User Guide

### Extend osixia/openldap:1.1.8 image
### Extend osixia/openldap:1.1.9 image

If you need to add your custom TLS certificate, bootstrap config or environment files the easiest way is to extends this image.

Dockerfile example:

FROM osixia/openldap:1.1.8
FROM osixia/openldap:1.1.9
MAINTAINER Your Name <[email protected]>

ADD bootstrap /container/service/slapd/assets/config/bootstrap
Expand All @@ -345,7 +372,7 @@ Clone this project:
Adapt Makefile, set your image NAME and VERSION, for example:

NAME = osixia/openldap
VERSION = 1.1.8
VERSION = 1.1.9

become:
NAME = cool-guy/openldap
Expand Down
5 changes: 4 additions & 1 deletion example/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
openldap:
image: osixia/openldap:1.1.8
image: osixia/openldap:1.1.9
container_name: openldap
environment:
LDAP_LOG_LEVEL: "256"
Expand All @@ -13,6 +13,7 @@ services:
LDAP_READONLY_USER: "false"
#LDAP_READONLY_USER_USERNAME: "readonly"
#LDAP_READONLY_USER_PASSWORD: "readonly"
LDAP_RFC2307BIS_SCHEMA: "false"
LDAP_BACKEND: "hdb"
LDAP_TLS: "true"
LDAP_TLS_CRT_FILENAME: "ldap.crt"
Expand All @@ -26,6 +27,7 @@ services:
#LDAP_REPLICATION_CONFIG_SYNCPROV: "binddn="cn=admin,cn=config" bindmethod=simple credentials=$LDAP_CONFIG_PASSWORD searchbase="cn=config" type=refreshAndPersist retry="60 +" timeout=1 starttls=critical"
#LDAP_REPLICATION_DB_SYNCPROV: "binddn="cn=admin,$LDAP_BASE_DN" bindmethod=simple credentials=$LDAP_ADMIN_PASSWORD searchbase="$LDAP_BASE_DN" type=refreshAndPersist interval=00:00:00:10 retry="60 +" timeout=1 starttls=critical"
#LDAP_REPLICATION_HOSTS: "#PYTHON2BASH:['ldap://ldap.example.org','ldap://ldap2.example.org']"
KEEP_EXISTING_CONFIG: "false"
LDAP_REMOVE_CONFIG_AFTER_SETUP: "true"
LDAP_SSL_HELPER_PREFIX: "ldap"
tty: true
Expand All @@ -37,6 +39,7 @@ services:
ports:
- "389:389"
- "636:636"
domainname: "example.org" # important: same as hostname
hostname: "example.org"
phpldapadmin:
image: osixia/phpldapadmin:latest
Expand Down
2 changes: 1 addition & 1 deletion example/extend-osixia-openldap/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM osixia/openldap:1.1.8
FROM osixia/openldap:1.1.9
MAINTAINER Your Name <[email protected]>

ADD bootstrap /container/service/slapd/assets/config/bootstrap
Expand Down
6 changes: 5 additions & 1 deletion example/kubernetes/simple/ldap-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
spec:
containers:
- name: ldap
image: osixia/openldap:1.1.8
image: osixia/openldap:1.1.9
volumeMounts:
- name: ldap-data
mountPath: /var/lib/ldap
Expand Down Expand Up @@ -41,6 +41,8 @@ spec:
value: "readonly"
- name: LDAP_READONLY_USER_PASSWORD
value: "readonly"
- name: LDAP_RFC2307BIS_SCHEMA
value: "false"
- name: LDAP_BACKEND
value: "hdb"
- name: LDAP_TLS
Expand All @@ -65,6 +67,8 @@ spec:
value: "binddn=\"cn=admin,$LDAP_BASE_DN\" bindmethod=simple credentials=$LDAP_ADMIN_PASSWORD searchbase=\"$LDAP_BASE_DN\" type=refreshAndPersist interval=00:00:00:10 retry=\"60 +\" timeout=1 starttls=critical"
- name: LDAP_REPLICATION_HOSTS
value: "#PYTHON2BASH:['ldap://ldap-one-service', 'ldap://ldap-two-service']"
- name: KEEP_EXISTING_CONFIG
value: "false"
- name: LDAP_REMOVE_CONFIG_AFTER_SETUP
value: "true"
- name: LDAP_SSL_HELPER_PREFIX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ LDAP_READONLY_USER: false
LDAP_READONLY_USER_USERNAME: readonly
LDAP_READONLY_USER_PASSWORD: readonly

LDAP_RFC2307BIS_SCHEMA: false

# Backend
LDAP_BACKEND: hdb

Expand Down Expand Up @@ -46,6 +48,12 @@ LDAP_REPLICATION_HOSTS:
- ldap://ldap2.example.org


# Do not change the ldap config
# - If set to true with an existing database, config will remain unchanged. Image tls and replication config will not be run.
# The container can be started with LDAP_ADMIN_PASSWORD and LDAP_CONFIG_PASSWORD empty or filled with fake data.
# - If set to true when bootstrapping a new database, bootstap ldif and schema will not be added and tls and replication config will not be run.
KEEP_EXISTING_CONFIG: false

# Remove config after setup
LDAP_REMOVE_CONFIG_AFTER_SETUP: true

Expand Down
2 changes: 1 addition & 1 deletion example/kubernetes/using-secrets/ldap-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
spec:
containers:
- name: ldap
image: osixia/openldap:1.1.8
image: osixia/openldap:1.1.9
args: ["--copy-service"]
volumeMounts:
- name: ldap-data
Expand Down
10 changes: 8 additions & 2 deletions image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Use osixia/light-baseimage
# sources: https://github.com/osixia/docker-light-baseimage
FROM osixia/light-baseimage:0.2.6
FROM osixia/light-baseimage:1.1.0
MAINTAINER Bertrand Gouny <[email protected]>

# Add openldap user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
Expand All @@ -11,8 +11,14 @@ RUN groupadd -r openldap && useradd -r -g openldap openldap
#  https://github.com/osixia/docker-light-baseimage/blob/stable/image/service-available/:ssl-tools/download.sh
RUN apt-get -y update \
&& /container/tool/add-service-available :ssl-tools \
&& LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes --no-install-recommends \
&& LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ldap-utils \
libsasl2-modules \
libsasl2-modules-db \
libsasl2-modules-gssapi-mit \
libsasl2-modules-ldap \
libsasl2-modules-otp \
libsasl2-modules-sql \
openssl \
slapd \
&& apt-get clean \
Expand Down
Loading

0 comments on commit aee8721

Please sign in to comment.