From 5c658b823d5687b4a259fe35de87542db0b6ec4e Mon Sep 17 00:00:00 2001 From: J0WI Date: Tue, 15 May 2018 01:31:55 +0200 Subject: [PATCH] Add Alpine variant --- .travis.yml | 2 + Dockerfile-alpine.template | 83 +++++++++++++++++++ ...ile.template => Dockerfile-debian.template | 0 fpm-alpine/Dockerfile | 83 +++++++++++++++++++ fpm-alpine/docker-entrypoint.sh | 9 ++ fpm-alpine/php.ini | 3 + update.sh | 12 ++- 7 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 Dockerfile-alpine.template rename Dockerfile.template => Dockerfile-debian.template (100%) create mode 100644 fpm-alpine/Dockerfile create mode 100755 fpm-alpine/docker-entrypoint.sh create mode 100644 fpm-alpine/php.ini diff --git a/.travis.yml b/.travis.yml index 1fe69de9..bb376611 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,8 @@ install: - git clone https://github.com/docker-library/official-images.git ~/official-images script: + - travis_retry docker build -t piwik:fpm-alpine fpm-alpine + - ~/official-images/test/run.sh piwik:fpm-alpine - travis_retry docker build -t piwik:fpm fpm - ~/official-images/test/run.sh piwik:fpm - travis_retry docker build -t piwik:apache apache diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template new file mode 100644 index 00000000..43a65e12 --- /dev/null +++ b/Dockerfile-alpine.template @@ -0,0 +1,83 @@ +FROM php:7.1-%%VARIANT%% + +LABEL maintainer="pierre@piwik.org" + +RUN set -ex; \ + \ + apk add --no-cache --virtual .build-deps \ + alpine-sdk \ + autoconf \ + freetype-dev \ + geoip-dev \ + icu-dev \ + libjpeg-turbo-dev \ + libpng-dev \ + openldap-dev \ + pcre-dev \ + ; \ + \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap; \ + docker-php-ext-install \ + gd \ + ldap \ + mysqli \ + opcache \ + pdo_mysql \ + zip \ + ; \ + \ + pecl install \ + APCu-5.1.11 \ + geoip-1.1.1 \ + redis-3.1.6 \ + ; \ + \ + docker-php-ext-enable \ + apcu \ + geoip \ + redis \ + ; \ + \ + 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 .piwik-phpext-rundeps $runDeps; \ + apk del .build-deps + +ENV MATOMO_VERSION %%VERSION%% + +RUN set -ex; \ + apk add --no-cache --virtual .fetch-deps \ + gnupg \ + ; \ + \ + curl -fsSL -o piwik.tar.gz \ + "https://builds.matomo.org/piwik-${MATOMO_VERSION}.tar.gz"; \ + curl -fsSL -o piwik.tar.gz.asc \ + "https://builds.matomo.org/piwik-${MATOMO_VERSION}.tar.gz.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 814E346FA01A20DBB04B6807B5DBD5925590A237; \ + gpg --batch --verify piwik.tar.gz.asc piwik.tar.gz; \ + rm -r "$GNUPGHOME" piwik.tar.gz.asc; \ + tar -xzf piwik.tar.gz -C /usr/src/; \ + rm piwik.tar.gz; \ + apk del .fetch-deps + +COPY php.ini /usr/local/etc/php/conf.d/php-piwik.ini + +RUN set -ex; \ + curl -fsSL -o /usr/src/piwik/misc/GeoIPCity.dat.gz https://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz; \ + gunzip /usr/src/piwik/misc/GeoIPCity.dat.gz + +COPY docker-entrypoint.sh /entrypoint.sh + +# WORKDIR is /var/www/html (inherited via "FROM php") +# "/entrypoint.sh" will populate it at container startup from /usr/src/piwik +VOLUME /var/www/html + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["%%CMD%%"] diff --git a/Dockerfile.template b/Dockerfile-debian.template similarity index 100% rename from Dockerfile.template rename to Dockerfile-debian.template diff --git a/fpm-alpine/Dockerfile b/fpm-alpine/Dockerfile new file mode 100644 index 00000000..eaddf0ea --- /dev/null +++ b/fpm-alpine/Dockerfile @@ -0,0 +1,83 @@ +FROM php:7.1-fpm-alpine + +LABEL maintainer="pierre@piwik.org" + +RUN set -ex; \ + \ + apk add --no-cache --virtual .build-deps \ + alpine-sdk \ + autoconf \ + freetype-dev \ + geoip-dev \ + icu-dev \ + libjpeg-turbo-dev \ + libpng-dev \ + openldap-dev \ + pcre-dev \ + ; \ + \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap; \ + docker-php-ext-install \ + gd \ + ldap \ + mysqli \ + opcache \ + pdo_mysql \ + zip \ + ; \ + \ + pecl install \ + APCu-5.1.11 \ + geoip-1.1.1 \ + redis-3.1.6 \ + ; \ + \ + docker-php-ext-enable \ + apcu \ + geoip \ + redis \ + ; \ + \ + 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 .piwik-phpext-rundeps $runDeps; \ + apk del .build-deps + +ENV MATOMO_VERSION 3.5.0 + +RUN set -ex; \ + apk add --no-cache --virtual .fetch-deps \ + gnupg \ + ; \ + \ + curl -fsSL -o piwik.tar.gz \ + "https://builds.matomo.org/piwik-${MATOMO_VERSION}.tar.gz"; \ + curl -fsSL -o piwik.tar.gz.asc \ + "https://builds.matomo.org/piwik-${MATOMO_VERSION}.tar.gz.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ + gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 814E346FA01A20DBB04B6807B5DBD5925590A237; \ + gpg --batch --verify piwik.tar.gz.asc piwik.tar.gz; \ + rm -r "$GNUPGHOME" piwik.tar.gz.asc; \ + tar -xzf piwik.tar.gz -C /usr/src/; \ + rm piwik.tar.gz; \ + apk del .fetch-deps + +COPY php.ini /usr/local/etc/php/conf.d/php-piwik.ini + +RUN set -ex; \ + curl -fsSL -o /usr/src/piwik/misc/GeoIPCity.dat.gz https://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz; \ + gunzip /usr/src/piwik/misc/GeoIPCity.dat.gz + +COPY docker-entrypoint.sh /entrypoint.sh + +# WORKDIR is /var/www/html (inherited via "FROM php") +# "/entrypoint.sh" will populate it at container startup from /usr/src/piwik +VOLUME /var/www/html + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] diff --git a/fpm-alpine/docker-entrypoint.sh b/fpm-alpine/docker-entrypoint.sh new file mode 100755 index 00000000..c7093b59 --- /dev/null +++ b/fpm-alpine/docker-entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e + +if [ ! -e piwik.php ]; then + tar cf - --one-file-system -C /usr/src/piwik . | tar xf - + chown -R www-data . +fi + +exec "$@" diff --git a/fpm-alpine/php.ini b/fpm-alpine/php.ini new file mode 100644 index 00000000..837be2ab --- /dev/null +++ b/fpm-alpine/php.ini @@ -0,0 +1,3 @@ +always_populate_raw_post_data=-1 +geoip.custom_directory=/var/www/html/misc +display_errors=Off diff --git a/update.sh b/update.sh index e4602692..3d4d8143 100755 --- a/update.sh +++ b/update.sh @@ -4,6 +4,13 @@ set -e declare -A cmd=( [apache]='apache2-foreground' [fpm]='php-fpm' + [fpm-alpine]='php-fpm' +) + +declare -A base=( + [apache]='debian' + [fpm]='debian' + [fpm-alpine]='alpine' ) latest="$( @@ -16,8 +23,9 @@ latest="$( set -x -for variant in apache fpm; do - cp Dockerfile.template "$variant/Dockerfile" +for variant in apache fpm fpm-alpine; do + template="Dockerfile-${base[$variant]}.template" + cp $template "$variant/Dockerfile" cp docker-entrypoint.sh "$variant/docker-entrypoint.sh" cp php.ini "$variant/php.ini" sed -ri -e '