diff --git a/CHANGELOG.md b/CHANGELOG.md index 02828e9..5e7cd20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.6.8 + - Upgrade baseimage: web-baseimage:0.1.9 + ## 0.6.7 - Upgrade baseimage: web-baseimage:0.1.8 diff --git a/Makefile b/Makefile index aaf479a..f710dbc 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ NAME = osixia/phpldapadmin -VERSION = 0.6.7 +VERSION = 0.6.8 .PHONY: all build build-nocache test tag_latest release diff --git a/README.md b/README.md index 45d73aa..53ceaaa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ # osixia/phpldapadmin -[![](https://badge.imagelayers.io/osixia/phpldapadmin:latest.svg)](https://imagelayers.io/?images=osixia/phpldapadmin:latest 'Get your own badge on imagelayers.io') | Latest release: 0.6.7 - [Changelog](CHANGELOG.md) | [Docker Hub](https://hub.docker.com/r/osixia/phpldapadmin/)  +[![Docker Pulls](https://img.shields.io/docker/pulls/osixia/phpldapadmin.svg)][hub] +[![Docker Stars](https://img.shields.io/docker/stars/osixia/phpldapadmin.svg)][hub] +[![Image Size](https://img.shields.io/imagelayers/image-size/osixia/phpldapadmin/latest.svg)](https://imagelayers.io/?images=osixia/phpldapadmin:latest) +[![Image Layers](https://img.shields.io/imagelayers/layers/osixia/phpldapadmin/latest.svg)](https://imagelayers.io/?images=osixia/phpldapadmin:latest) + +[hub]: https://hub.docker.com/r/osixia/phpldapadmin/ + +Latest release: 0.6.8 - phpLDAPadlin 1.2.3 (with php5.5 patch) - [Changelog](CHANGELOG.md) | [Docker Hub](https://hub.docker.com/r/osixia/phpldapadmin/)  A docker image to run phpLDAPadmin. > [phpldapadmin.sourceforge.net](http://phpldapadmin.sourceforge.net) @@ -13,6 +20,7 @@ A docker image to run phpLDAPadmin. - [Use autogenerated certificate](#use-autogenerated-certificate) - [Use your own certificate](#use-your-own-certificate) - [Disable HTTPS](#disable-https) + - [Fix docker mounted file problems](#fix-docker-mounted-file-problems) - [Debug](#debug) - [Environment Variables](#environment-variables) - [Set your own environment variables](#set-your-own environment-variables) @@ -20,7 +28,7 @@ A docker image to run phpLDAPadmin. - [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/phpldapadmin:0.6.7 image](#extend-osixiaphpldapadmin067-image) + - [Extend osixia/phpldapadmin:0.6.8 image](#extend-osixiaphpldapadmin068-image) - [Make your own phpLDAPadmin image](#make-your-own-phpldapadmin-image) - [Tests](#tests) - [Kubernetes](#kubernetes) @@ -33,7 +41,7 @@ Run a phpLDAPadmin docker image by replacing `ldap.example.com` with your ldap h docker run -p 6443:443 \ --env PHPLDAPADMIN_LDAP_HOSTS=ldap.example.com \ - --detach osixia/phpldapadmin:0.6.7 + --detach osixia/phpldapadmin:0.6.8 That's it :) you can access phpLDAPadmin on [https://localhost:6443](https://localhost:6443) @@ -42,16 +50,11 @@ That's it :) you can access phpLDAPadmin on [https://localhost:6443](https://loc Example script: #!/bin/bash -e + docker run --name ldap-service --hostname ldap-service --detach osixia/openldap:1.1.1 - # Run a ldap server, save the container id in LDAP_CID and get its IP: - LDAP_CID=$(docker run --hostname ldap.example.org --detach osixia/openldap:1.1.0) - LDAP_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $LDAP_CID) + docker run --name phpldapadmin-service --hostname phpldapadmin-service --link ldap-service:ldap-host --env PHPLDAPADMIN_LDAP_HOSTS=ldap-host --detach osixia/phpldapadmin:0.6.8 - # Run phpLDAPadmin and set ldap host to ldap ip - PHPLDAP_CID=$(docker run --hostname phpldapadmin.example.org --env PHPLDAPADMIN_LDAP_HOSTS=$LDAP_IP --detach osixia/phpldapadmin:0.6.7) - - # We get phpLDAPadmin container ip - PHPLDAP_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $PHPLDAP_CID) + PHPLDAP_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" phpldapadmin-service) echo "Go to: https://$PHPLDAP_IP" echo "Login DN: cn=admin,dc=example,dc=org" @@ -66,7 +69,7 @@ but setting your own config.php is possible. 2 options: - Link your config file at run time to `/container/service/phpldapadmin/assets/config.php` : - docker run --volume /data/my-config.php:/container/service/phpldapadmin/assets/config.php --detach osixia/phpldapadmin:0.6.7 + docker run --volume /data/my-config.php:/container/service/phpldapadmin/assets/config.php --detach osixia/phpldapadmin:0.6.8 - Add your config file by extending or cloning this image, please refer to the [Advanced User Guide](#advanced-user-guide) @@ -75,7 +78,7 @@ but setting your own config.php is possible. 2 options: #### Use autogenerated certificate By default HTTPS is enable, a certificate is created with the container hostname (it can be set by docker run --hostname option eg: phpldapadmin.my-company.com). - docker run --hostname phpldapadmin.my-company.com --detach osixia/phpldapadmin:0.6.7 + docker run --hostname phpldapadmin.my-company.com --detach osixia/phpldapadmin:0.6.8 #### Use your own certificate @@ -85,14 +88,22 @@ You can set your custom certificate at run time, by mounting a directory contain --env PHPLDAPADMIN_HTTPS_CRT_FILENAME=my-cert.crt \ --env PHPLDAPADMIN_HTTPS_KEY_FILENAME=my-cert.key \ --env PHPLDAPADMIN_HTTPS_CA_CRT_FILENAME=the-ca.crt \ - --detach osixia/phpldapadmin:0.6.7 + --detach osixia/phpldapadmin:0.6.8 Other solutions are available please refer to the [Advanced User Guide](#advanced-user-guide) #### Disable HTTPS Add --env PHPLDAPADMIN_HTTPS=false to the run command : - docker run --env PHPLDAPADMIN_HTTPS=false --detach osixia/phpldapadmin:0.6.7 + docker run --env PHPLDAPADMIN_HTTPS=false --detach osixia/phpldapadmin:0.6.8 + +### Fix docker mounted file problems + +You may have some problems with mounted files on some systems. The startup script try to make some file adjustment and fix files owner and permissions, this can result in multiple errors. See [Docker documentation](https://docs.docker.com/v1.4/userguide/dockervolumes/#mount-a-host-file-as-a-data-volume). + +To fix that run the container with `--copy-service` argument : + + docker run [your options] osixia/phpldapadmin:0.6.8 --copy-service ### Debug @@ -101,11 +112,11 @@ Available levels are: `none`, `error`, `warning`, `info`, `debug` and `trace`. Example command to run the container in `debug` mode: - docker run --detach osixia/phpldapadmin:0.6.7 --loglevel debug + docker run --detach osixia/phpldapadmin:0.6.8 --loglevel debug See all command line options: - docker run osixia/phpldapadmin:0.6.7 --help + docker run osixia/phpldapadmin:0.6.8 --help ## Environment Variables @@ -158,7 +169,7 @@ See how to [set your own environment variables](#set-your-own-environment-variab If you want to set this variable at docker run command add the tag `#PYTHON2BASH:` and convert the yaml in python: - docker run --env PHPLDAPADMIN_LDAP_HOSTS="#PYTHON2BASH:[{'ldap.example.org': [{'server': [{'tls': True}]},{'login': [{'bind_id': 'cn=admin,dc=example,dc=org'}]}]}, 'ldap2.example.org', 'ldap3.example.org']" --detach osixia/phpldapadmin:0.6.7 + docker run --env PHPLDAPADMIN_LDAP_HOSTS="#PYTHON2BASH:[{'ldap.example.org': [{'server': [{'tls': True}]},{'login': [{'bind_id': 'cn=admin,dc=example,dc=org'}]}]}, 'ldap2.example.org', 'ldap3.example.org']" --detach osixia/phpldapadmin:0.6.8 To convert yaml to python online: http://yaml-online-parser.appspot.com/ @@ -191,14 +202,14 @@ Other environment variables: Environment variables can be set by adding the --env argument in the command line, for example: docker run --env PHPLDAPADMIN_LDAP_HOSTS="ldap.example.org" \ - --detach osixia/phpldapadmin:0.6.7 + --detach osixia/phpldapadmin:0.6.8 #### Link environment file For example if your environment file is in : /data/environment/my-env.yaml docker run --volume /data/environment/my-env.yaml:/container/environment/01-custom/env.yaml \ - --detach osixia/phpldapadmin:0.6.7 + --detach osixia/phpldapadmin:0.6.8 Take care to link your environment file 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). @@ -208,13 +219,13 @@ This is the best solution if you have a private registry. Please refer to the [A ## Advanced User Guide -### Extend osixia/phpldapadmin:0.6.7 image +### Extend osixia/phpldapadmin:0.6.8 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/phpldapadmin:0.6.7 + FROM osixia/phpldapadmin:0.6.8 MAINTAINER Your Name ADD https-certs /container/service/phpldapadmin/assets/apache2/certs @@ -233,7 +244,7 @@ Clone this project : Adapt Makefile, set your image NAME and VERSION, for example : NAME = osixia/phpldapadmin - VERSION = 0.6.7 + VERSION = 0.6.8 becomes : NAME = billy-the-king/phpldapadmin diff --git a/example/kubernetes/phpldapadmin-rc.yaml b/example/kubernetes/phpldapadmin-rc.yaml index d5363f8..eb84b4e 100644 --- a/example/kubernetes/phpldapadmin-rc.yaml +++ b/example/kubernetes/phpldapadmin-rc.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: phpldapadmin - image: osixia/phpldapadmin:0.6.7 + image: osixia/phpldapadmin:0.6.8 volumeMounts: - name: phpldapadmin-certs mountPath: /container/service/phpldapadmin/assets/apache2/certs diff --git a/image/Dockerfile b/image/Dockerfile index c458400..f510e20 100644 --- a/image/Dockerfile +++ b/image/Dockerfile @@ -1,4 +1,4 @@ -FROM osixia/web-baseimage:0.1.8 +FROM osixia/web-baseimage:0.1.9 MAINTAINER Bertrand Gouny # phpLDAPadmin version @@ -27,17 +27,17 @@ RUN apt-get update \ && echo "$PHPLDAPADMIN_SHA1 *phpldapadmin.tgz" | sha1sum -c - \ && mkdir -p /var/www/phpldapadmin_bootstrap /var/www/phpldapadmin \ && tar -xzf phpldapadmin.tgz --strip 1 -C /var/www/phpldapadmin_bootstrap \ - && apt-get remove -y --purge --auto-remove curl ca-certificates + && apt-get remove -y --purge --auto-remove curl ca-certificates \ + && rm phpldapadmin.tgz \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Add service directory to /container/service ADD service /container/service -# Use baseimage install-service script and clean all +# Use baseimage install-service script # https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/install-service -RUN /container/tool/install-service \ - && rm phpldapadmin.tgz \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +RUN /container/tool/install-service # Add default env variables ADD environment /container/environment/99-default diff --git a/image/service/phpldapadmin/startup.sh b/image/service/phpldapadmin/startup.sh index 5edd24b..95df911 100755 --- a/image/service/phpldapadmin/startup.sh +++ b/image/service/phpldapadmin/startup.sh @@ -4,6 +4,8 @@ # https://github.com/osixia/docker-light-baseimage/blob/stable/image/tool/log-helper log-helper level eq trace && set -x +FIRST_START_DONE="${CONTAINER_STATE_DIR}/docker-phpldapadmin-first-start-done" + # # HTTPS config # @@ -31,20 +33,23 @@ fi a2ensite phpldapadmin | log-helper debug -FIRST_START_DONE="${CONTAINER_STATE_DIR}/docker-phpldapadmin-first-start-done" -# container first start -if [ ! -e "$FIRST_START_DONE" ]; then +# +# phpLDAPadmin directory is empty, we use the bootstrap +# +if [ ! "$(ls -A /var/www/phpldapadmin)" ]; then - # - # phpLDAPadmin directory is empty, we use the bootstrap - # - if [ ! "$(ls -A /var/www/phpldapadmin)" ]; then + log-helper info "Bootstap phpLDAPadmin..." - log-helper info "Bootstap phpLDAPadmin..." + cp -R /var/www/phpldapadmin_bootstrap/* /var/www/phpldapadmin + rm -rf /var/www/phpldapadmin_bootstrap + rm -f /var/www/phpldapadmin/config/config.php +fi - cp -R /var/www/phpldapadmin_bootstrap/* /var/www/phpldapadmin - rm -rf /var/www/phpldapadmin_bootstrap - rm -f /var/www/phpldapadmin/config/config.php +# if there is no config +if [ ! -e "/var/www/phpldapadmin/config/config.php" ]; then + + # on container first start customise the container config file + if [ ! -e "$FIRST_START_DONE" ]; then get_salt() { salt=$(,()*.^@$% =-_~;:/{}[]+!`azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN' | head -c64 | tr -d '\\') @@ -118,15 +123,13 @@ if [ ! -e "$FIRST_START_DONE" ]; then done sed -i "/{{ PHPLDAPADMIN_SERVERS }}/d" ${CONTAINER_SERVICE_DIR}/phpldapadmin/assets/config.php - fi - touch $FIRST_START_DONE -fi + touch $FIRST_START_DONE + fi -# if there is no config file link service config -if [ ! -e "/var/www/phpldapadmin/config/config.php" ]; then - log-helper debug "link ${CONTAINER_SERVICE_DIR}/phpldapadmin/assets/config.php to /var/www/phpldapadmin/config/config.php" + log-helper debug "link ${CONTAINER_SERVICE_DIR}/phpldapadmin/assets/config.php to /var/www/phpldapadmin/config/config.php" ln -sf ${CONTAINER_SERVICE_DIR}/phpldapadmin/assets/config.php /var/www/phpldapadmin/config/config.php + fi # fix file permission diff --git a/test/test.bats b/test/test.bats index f7bd932..ffa2b04 100644 --- a/test/test.bats +++ b/test/test.bats @@ -29,7 +29,7 @@ load test_helper tmp_file="$BATS_TMPDIR/docker-test" # we start a new openldap container - LDAP_CID=$(docker run -d osixia/openldap:1.1.0) + LDAP_CID=$(docker run -d osixia/openldap:1.1.1) LDAP_IP=$(get_container_ip_by_cid $LDAP_CID) # we start the wordpress container and set DB_HOSTS