diff --git a/docker/Dockerfile.common b/docker/Dockerfile.common index b035351e..947eca3e 100644 --- a/docker/Dockerfile.common +++ b/docker/Dockerfile.common @@ -1,37 +1,55 @@ -# Update/upgrade -RUN apt-get update -RUN apt-get upgrade -y -# Install LdapSaisie APT repository -RUN apt-get install -y --force-yes wget gnupg lsb-release -RUN wget -O - http://ldapsaisie.org/debian/ldapsaisie.gpg.key | apt-key add - -RUN echo "deb http://ldapsaisie.org/debian $( lsb_release -c -s ) main" > /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 iproute2 net-tools composer php-cas php-zxcvbn php-phpseclib php-zip -# 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 vimrc.local file -COPY vimrc.local /etc/vim/vimrc.local +ARG DEBIAN_FRONTEND=noninteractive + +# Update/upgrade, configure LdapSaisie APT repo and install dependencies +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y --force-yes wget gnupg lsb-release && \ + wget -O - http://ldapsaisie.org/debian/ldapsaisie.gpg.key | apt-key add - && \ + echo "deb http://ldapsaisie.org/debian $( lsb_release -c -s ) main" > /etc/apt/sources.list.d/ldapsaisie.list && \ + apt-get update && \ + 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-html2text \ + php-console-table \ + ldapvi \ + locales \ + sed \ + bash-completion \ + liquidprompt \ + vim \ + curl \ + jq \ + iproute2 \ + net-tools \ + composer \ + php-cas \ + php-zxcvbn \ + php-phpseclib \ + php-zip && \ + apt-get clean && \ + rm -fr rm -rf /var/lib/apt/lists/* +COPY rootfs / +# Install LdapSaisie from sources, configure slapd and load lsexample directory +RUN git clone https://gitlab.easter-eggs.com/ee/ldapsaisie.git /var/www/ldapsaisie && \ + ln -s /var/www/ldapsaisie/src/bin/ldapsaisie.php /usr/local/sbin/ldapsaisie && \ + ln -s /var/www/ldapsaisie/debian/ldapsaisie.bash-completion /usr/share/bash-completion/completions/ldapsaisie && \ + chown www-data: -R /var/www/ldapsaisie/src/tmp/ && \ + sed -i 's/^# fr_FR/fr_FR/' /etc/locale.gen && \ + locale-gen && \ + a2dissite 000-default && \ + a2ensite ldapsaisie && \ + a2enmod rewrite && \ + /var/www/ldapsaisie/lsexample/restore_lsexample -v # 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 +ENTRYPOINT /entrypoint.sh EXPOSE 80 389 diff --git a/docker/build-and-push-all.sh b/docker/build-and-push-all.sh old mode 100644 new mode 100755 index b1da5e5b..6d361686 --- a/docker/build-and-push-all.sh +++ b/docker/build-and-push-all.sh @@ -1,6 +1,7 @@ #!/bin/bash cd $( dirname $0 ) +DIST="$1" # Need to use Dockerfile+ (https://github.com/edrevo/dockerfile-plus) export DOCKER_BUILDKIT=1 @@ -10,9 +11,12 @@ LATEST_DIST=${DISTS[0]} for dist in ${DISTS[@]} do - docker build -t brenard/ldapsaisie:$dist -f Dockerfile.$dist . - [ $? -eq 0 ] && docker push brenard/ldapsaisie:$dist + [ -n "$DIST" -a "$DIST" != "$dist" ] && continue + docker build -t docker.io/brenard/ldapsaisie:$dist -f Dockerfile.$dist . + [ $? -eq 0 ] && docker push docker.io/brenard/ldapsaisie:$dist done -docker build -t brenard/ldapsaisie:latest -f Dockerfile.$LATEST_DIST . -[ $? -eq 0 ] && docker push brenard/ldapsaisie:latest +[ -n "$DIST" -a "$DIST" != "latest" ] && exit + +docker build -t docker.io/brenard/ldapsaisie:latest -f Dockerfile.$LATEST_DIST . +[ $? -eq 0 ] && docker push docker.io/brenard/ldapsaisie:latest diff --git a/docker/bashrc b/docker/rootfs/.bashrc similarity index 100% rename from docker/bashrc rename to docker/rootfs/.bashrc diff --git a/docker/entrypoint.sh b/docker/rootfs/entrypoint.sh similarity index 100% rename from docker/entrypoint.sh rename to docker/rootfs/entrypoint.sh diff --git a/docker/apache2.conf b/docker/rootfs/etc/apache2/sites-available/ldapsaisie.conf similarity index 100% rename from docker/apache2.conf rename to docker/rootfs/etc/apache2/sites-available/ldapsaisie.conf diff --git a/docker/vimrc.local b/docker/rootfs/etc/vim/vimrc.local similarity index 100% rename from docker/vimrc.local rename to docker/rootfs/etc/vim/vimrc.local