Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
Add Alpine variant
Browse files Browse the repository at this point in the history
  • Loading branch information
J0WI authored and pierreozoux committed May 15, 2018
1 parent e96a89c commit 5c658b8
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
83 changes: 83 additions & 0 deletions Dockerfile-alpine.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
FROM php:7.1-%%VARIANT%%

LABEL maintainer="[email protected]"

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%%"]
File renamed without changes.
83 changes: 83 additions & 0 deletions fpm-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
FROM php:7.1-fpm-alpine

LABEL maintainer="[email protected]"

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"]
9 changes: 9 additions & 0 deletions fpm-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
3 changes: 3 additions & 0 deletions fpm-alpine/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
always_populate_raw_post_data=-1
geoip.custom_directory=/var/www/html/misc
display_errors=Off
12 changes: 10 additions & 2 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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="$(
Expand All @@ -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 '
Expand Down

0 comments on commit 5c658b8

Please sign in to comment.