Warning: A non-numeric value encountered in /home/guillerm/public_html/wp-content/themes/Builder-Cohen/lib/builder-core/lib/layout-engine/modules/class-layout-module.php on line 499

OpenDJ Docker Image for Integration Testing

As I mentioned in my previous post I’ve been playing with Docker lately trying to build an OpenDJ image that I could use for integration testing. Before digging deeper into my testing strategy I decided to publish this short post to explain how such image can be created using a simple Dockerfile.

You can go ahead and download the project from Github if you want to play with it. This is what the Dockerfile looks like:

Let’s look at this file line by line.

The base image is java:8 which is available from the public Docker Hub and, as the name implies, provides us with an image that has Java 8 already installed.

We need to expose the OpenDJ ports so that we can connect to them once the container is running:

  • 1389: LDAP port
  • 1636: LDAPS port
  • 4444: Admin port

By default the Dockerfile expect to find the OpenDJ binaries in a file called opendj.zip. You can download any OpenDJ version from the Fogerock Backstage page, rename it to opendj.zip and move it to the project folder.

If you prefer to use the nightly build you can comment out the previous line and uncomment the following one:

Once the OpenDJ zip file has been added we need to extract the contents to the installation directory:

And then run the installation script:

Besides specifying ports and hostname we also have to choose a base DN, password for the “cn=Directory Manager” user,  and tell the script not to start OpenDJ just yet.

I decided to add the following lines at the end to be able to load a custom schema file and some sample data to initialize our directory:

And finally, this line tells Docker which command to run when the container starts:

We need to start OpenDJ in no-detach mode to keep the container running afterwards.

And that’s it! You can build and spin up a container by running the following commands (feel free to use your own image name and port mappings):

Be advised that any changes made after the container was started (via ldapmodify for example) will be lost once the container is stopped. This was put in place intentionally to make sure our integration tests always work with the same pre-define data.

Enjoy!

Comments


Warning: A non-numeric value encountered in /home/guillerm/public_html/wp-content/themes/Builder-Cohen/lib/builder-core/lib/layout-engine/modules/class-layout-module.php on line 499