From c4e9a33d2d2857ac6d13a55005df27c9d5b2eef5 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 8 Jun 2022 14:24:35 +0200 Subject: [PATCH] Add docker image --- docker/Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ docker/README.md | 14 ++++++++++++++ docker/apache2.conf | 11 +++++++++++ docker/apt.list | 1 + docker/bashrc | 7 +++++++ docker/entrypoint.sh | 5 +++++ 6 files changed, 74 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md create mode 100644 docker/apache2.conf create mode 100644 docker/apt.list create mode 100644 docker/bashrc create mode 100755 docker/entrypoint.sh diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..33f1fb7e --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,36 @@ +FROM debian:11 +# Update/upgrade +RUN apt-get update +RUN apt-get upgrade -y +# Install LdapSaisie APT repository +RUN apt-get install -y wget gnupg +RUN wget -O - http://ldapsaisie.org/debian/ldapsaisie.gpg.key | apt-key add - +COPY apt.list /etc/apt/sources.list.d/ldapsaisie.list +RUN apt-get update +# Install dependencies +RUN DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt-get install -y git slapd apache2 php-ldap libapache2-mod-php php-cli smarty3 php-net-ldap2 php-net-ftp php-mail php-mail-mime php-console-table ldapvi locales sed bash-completion liquidprompt vim curl jq +# Add fr_FR* locales +RUN sed -i 's/^# fr_FR/fr_FR/' /etc/locale.gen +RUN locale-gen +# Clone sources +RUN git clone https://gitlab.easter-eggs.com/ee/ldapsaisie.git /var/www/ldapsaisie +# Fix www-data permission on temporary directory +RUN chown www-data: -R /var/www/ldapsaisie/src/tmp/ +# Configure slapd and load lsexample directory +RUN killall slapd || echo slapd is not running +RUN /var/www/ldapsaisie/lsexample/restore_lsexample -v +# Configure and enable ldapsaisie VirtualHost (as default) +RUN a2dissite 000-default +COPY apache2.conf /etc/apache2/sites-available/ldapsaisie.conf +RUN a2ensite ldapsaisie +RUN a2enmod rewrite +RUN service apache2 restart +# Install ldapsaisie binary (with its bash-completion config) +RUN ln -s /var/www/ldapsaisie/src/bin/ldapsaisie.php /usr/local/sbin/ldapsaisie +RUN ln -s /var/www/ldapsaisie/debian/ldapsaisie.bash-completion /usr/share/bash-completion/completions/ldapsaisie +# Install entrypoint +COPY bashrc /root/.bashrc +COPY entrypoint.sh /usr/local/sbin/entrypoint.sh +RUN echo "ldapsaisie-dev" > /etc/hostname +ENTRYPOINT /usr/local/sbin/entrypoint.sh +EXPOSE 80 389 diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000..283c4ba8 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,14 @@ +# LdapSaisie docker image + +This docker image permit to test LdapSaisie using _LSexample_ test LDAP directory and configuration. + +To use it, just run the following command : + +```bash +docker run -it -p 8080:80 -h ldapsaisie.dev brenard/ldapsaisie:dev +``` + +You could access LdapSaisie using : +- your Web browser on http://127.0.0.1:8080 (credentials: `admin/admin`) +- the `ldapsaisie` CLI command (for instance: `ldapsaisie search LSpeople`, run `ldapsaisie --help` for details) +- the API on http://127.0.0.1/api (for instance: `curl -u admin:admin http://127.0.0.1/api/1.0/object/LSpeople|jq`, see [documentation](https://ldapsaisie.org/doc/all-in-one/LdapSaisie.html#api-methods) for details) diff --git a/docker/apache2.conf b/docker/apache2.conf new file mode 100644 index 00000000..012f1960 --- /dev/null +++ b/docker/apache2.conf @@ -0,0 +1,11 @@ + + DocumentRoot /var/www/ldapsaisie/src/public_html + + + Options -Indexes +FollowSymLinks + AllowOverride FileInfo + + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + diff --git a/docker/apt.list b/docker/apt.list new file mode 100644 index 00000000..f78c8965 --- /dev/null +++ b/docker/apt.list @@ -0,0 +1 @@ +deb http://ldapsaisie.org/debian bullseye main diff --git a/docker/bashrc b/docker/bashrc new file mode 100644 index 00000000..e7b97adf --- /dev/null +++ b/docker/bashrc @@ -0,0 +1,7 @@ +HISTCONTROL=ignoreboth +HISTSIZE=1000 +HISTFILESIZE=2000 +source /etc/bash_completion + +# Only load liquidprompt in interactive shells, not from a script or from scp +echo $- | grep -q i 2>/dev/null && . /usr/share/liquidprompt/liquidprompt diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 00000000..bf036e9b --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +service slapd start +service apache2 start +bash -l