From 19a8746d16389d60b064e15375219039b4688d31 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 26 Aug 2021 15:09:00 +0200 Subject: [PATCH] adds the new docker template --- Dockerfile.template | 168 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 Dockerfile.template diff --git a/Dockerfile.template b/Dockerfile.template new file mode 100644 index 0000000..a37897e --- /dev/null +++ b/Dockerfile.template @@ -0,0 +1,168 @@ +{{ + def is_alpine: + env.variant | index("alpine") +-}} +# from https://downloads.joomla.org/technical-requirements +FROM php:{{ env.phpVersion }}-{{ env.variant }} +LABEL maintainer="{{ env.joomlaMaintainers }}" + +# Disable remote database security requirements. +ENV JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK=1 +{{ if is_alpine then ( -}} +# entrypoint.sh dependencies +RUN apk add --no-cache \ + bash +{{ ) else "" end -}} +{{ if env.variant == "apache" then ( -}} +# Enable Apache Rewrite Module +RUN a2enmod rewrite\ +{{ ) else "" end -}} +# Install the PHP extensions +RUN set -ex; \ +{{ if is_alpine then ( -}} + \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + autoconf \ + bzip2-dev \ + gmp-dev \ + libjpeg-turbo-dev \ + libmcrypt-dev \ + libmemcached-dev \ + libpng-dev \ + libzip-dev \ + openldap-dev \ + pcre-dev \ + postgresql-dev \ + ; \ + \ +{{ if env.phpVersion == "7.3" then ( -}} + docker-php-ext-configure gd --with-jpeg-dir=/usr --with-png-dir=/usr; \ +{{ ) else ( -}} + docker-php-ext-configure gd --with-jpeg; \ +{{ ) end -}} + docker-php-ext-configure ldap; \ + docker-php-ext-install -j "$(nproc)" \ + bz2 \ + gd \ + gmp \ + ldap \ + mysqli \ + pdo_mysql \ + pdo_pgsql \ + pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-{{ env.pecl_APCu }}; \ + pecl install mcrypt-{{ env.pecl_mcrypt }}; \ + pecl install memcached-{{ env.pecl_memcached }}; \ + pecl install redis-{{ env.pecl_redis }}; \ + \ + docker-php-ext-enable \ + apcu \ + mcrypt \ + memcached \ + redis \ + ; \ + rm -r /tmp/pear; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .joomla-phpext-rundeps $runDeps; \ + apk del .build-deps +{{ ) else ( -}} + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libbz2-dev \ + libgmp-dev \ + libjpeg-dev \ + libldap2-dev \ + libmcrypt-dev \ + libmemcached-dev \ + libpng-dev \ + libpq-dev \ + libzip-dev \ + ; \ + \ +{{ if env.phpVersion == "7.3" then ( -}} + docker-php-ext-configure gd --with-jpeg-dir=/usr --with-png-dir=/usr; \ +{{ ) else ( -}} + docker-php-ext-configure gd --with-jpeg; \ +{{ ) end -}} + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ + docker-php-ext-install -j "$(nproc)" \ + bz2 \ + gd \ + gmp \ + ldap \ + mysqli \ + pdo_mysql \ + pdo_pgsql \ + pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-{{ env.pecl_APCu }}; \ + pecl install memcached-{{ env.pecl_memcached }}; \ + pecl install redis-{{ env.pecl_redis }}; \ + \ + docker-php-ext-enable \ + apcu \ + memcached \ + redis \ + ; \ + rm -r /tmp/pear; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* +{{ ) end -}} + +VOLUME /var/www/html + +# Define Joomla version and expected SHA512 signature +ENV JOOMLA_VERSION {{ env.joomlaVersion }} +ENV JOOMLA_SHA512 {{ env.joomlaSha512 }} + +# Download package and extract to web volume +RUN set -ex; \ + curl -o joomla.tar.bz2 -SL https://github.com/joomla/joomla-cms/releases/download/${JOOMLA_VERSION}/Joomla_${JOOMLA_VERSION}-Stable-Full_Package.tar.bz2; \ + echo "$JOOMLA_SHA512 *joomla.tar.bz2" | sha512sum -c -; \ + mkdir /usr/src/joomla; \ + tar -xf joomla.tar.bz2 -C /usr/src/joomla; \ + rm joomla.tar.bz2; \ + chown -R www-data:www-data /usr/src/joomla + +# Copy init scripts and custom .htaccess +COPY docker-entrypoint.sh /entrypoint.sh +COPY makedb.php /makedb.php + +ENTRYPOINT ["/entrypoint.sh"] +{{ if env.variant == "apache" then ( -}} +CMD ["apache2-foreground"] +{{ ) else ( }} +CMD ["php-fpm"] +{{ ) end -}} + +# vim:set ft=dockerfile: