diff --git a/piwik/Dockerfile b/piwik/Dockerfile index d146d5b..35c0b4e 100644 --- a/piwik/Dockerfile +++ b/piwik/Dockerfile @@ -1,9 +1,12 @@ -FROM alpine:3.5 +FROM wonderfall/nginx-php ARG VERSION=3.0.3 ARG GPG_matthieu="814E 346F A01A 20DB B04B 6807 B5DB D592 5590 A237" -ENV UID=991 GID=991 +ENV UID=991 GID=991 \ + UPLOAD_MAX_SIZE=10M \ + MEMORY_LIMIT=256M \ + OPCACHE_MEM_SIZE=128M RUN BUILD_DEPS=" \ git \ @@ -16,31 +19,10 @@ RUN BUILD_DEPS=" \ gnupg" \ && apk -U upgrade && apk add \ ${BUILD_DEPS} \ - nginx \ - s6 \ - su-exec \ geoip \ tzdata \ - php7-fpm \ - php7-gd \ - php7-curl \ - php7-session \ - php7-json \ - php7-ctype \ - php7-mbstring \ - php7-iconv \ - php7-zlib \ - php7-dom \ - php7-openssl \ - php7-mysqli \ - php7-mysqlnd \ - php7-pdo \ - php7-pdo_mysql \ - php7-dev \ - php7-pear \ - && sed -i "$ s|\-n||g" /usr/bin/pecl && pecl install geoip-1.1.1 \ - && echo 'extension=geoip.so' >> /etc/php7/conf.d/00_geoip.ini \ - && echo 'geoip.custom_directory=/piwik/misc' >> /etc/php7/php.ini \ + && pecl install geoip-1.1.1 \ + && echo 'extension=geoip.so' >> /php/conf.d/geoip.ini \ && mkdir /piwik && cd /tmp \ && PIWIK_TARBALL="piwik-${VERSION}.tar.gz" \ && wget -q https://builds.piwik.org/${PIWIK_TARBALL} \ @@ -54,16 +36,13 @@ RUN BUILD_DEPS=" \ && if [ "${FINGERPRINT}" != "${GPG_matthieu}" ]; then echo "Warning! Wrong GPG fingerprint!" && exit 1; fi \ && echo "All seems good, now unpacking ${PIWIK_TARBALL}..." \ && tar xzf ${PIWIK_TARBALL} --strip 1 -C /piwik \ - && wget -q https://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz -P /piwik/misc \ - && gzip -d /piwik/misc/GeoLiteCity.dat.gz \ - && mv /piwik/misc/GeoLiteCity.dat /piwik/misc/GeoIPCity.dat \ + && wget -q https://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz -P /usr/share/GeoIP/ \ + && gzip -d /usr/share/GeoIP/GeoLiteCity.dat.gz \ + && mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat \ && apk del ${BUILD_DEPS} php7-dev php7-pear \ && rm -rf /var/cache/apk/* /tmp/* /root/.gnupg -COPY nginx.conf /etc/nginx/nginx.conf -COPY php-fpm.conf /etc/php7/php-fpm.conf -COPY s6.d /etc/s6.d -COPY run.sh /usr/local/bin/run.sh +COPY rootfs / RUN chmod +x /usr/local/bin/run.sh /etc/s6.d/*/* /etc/s6.d/.s6-svscan/* diff --git a/piwik/php-fpm.conf b/piwik/php-fpm.conf deleted file mode 100644 index f636044..0000000 --- a/piwik/php-fpm.conf +++ /dev/null @@ -1,11 +0,0 @@ -[global] -daemonize = no - -[www] -listen = /tmp/php-fpm.sock -pm = dynamic -pm.max_children = 5 -pm.start_servers = 2 -pm.min_spare_servers = 1 -pm.max_spare_servers = 3 -chdir = / diff --git a/piwik/nginx.conf b/piwik/rootfs/nginx/sites-enabled/nginx.conf similarity index 55% rename from piwik/nginx.conf rename to piwik/rootfs/nginx/sites-enabled/nginx.conf index 887e886..69ea84d 100644 --- a/piwik/nginx.conf +++ b/piwik/rootfs/nginx/sites-enabled/nginx.conf @@ -1,57 +1,4 @@ -worker_processes auto; -pid /tmp/nginx.pid; -daemon off; - -events { - worker_connections 1024; - use epoll; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - access_log off; - error_log /tmp/ngx_error.log error; - - fastcgi_temp_path /tmp/fastcgi 1 2; - client_body_temp_path /tmp/client_body 1 2; - proxy_temp_path /tmp/proxy 1 2; - uwsgi_temp_path /tmp/uwsgi 1 2; - scgi_temp_path /tmp/scgi 1 2; - - sendfile on; - keepalive_timeout 15; - keepalive_disable msie6; - keepalive_requests 100; - tcp_nopush on; - tcp_nodelay on; - server_tokens off; - - gzip on; - gzip_comp_level 5; - gzip_min_length 512; - gzip_buffers 4 8k; - gzip_proxied any; - gzip_vary on; - gzip_disable "msie6"; - gzip_types - text/css - text/javascript - text/xml - text/plain - text/x-component - application/javascript - application/x-javascript - application/json - application/xml - application/rss+xml - application/vnd.ms-fontobject - font/truetype - font/opentype - image/svg+xml; - - server { +server { listen 8888; root /piwik; index index.php index.html; @@ -92,11 +39,8 @@ http { location ~ \.php$ { fastcgi_index index.php; - fastcgi_pass unix:/tmp/php-fpm.sock; + fastcgi_pass unix:/php/run/php-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include /etc/nginx/fastcgi_params; + include /nginx/conf/fastcgi_params; } - - } - } diff --git a/piwik/rootfs/php/conf.d/opcache.ini b/piwik/rootfs/php/conf.d/opcache.ini new file mode 100644 index 0000000..d77112b --- /dev/null +++ b/piwik/rootfs/php/conf.d/opcache.ini @@ -0,0 +1,8 @@ +zend_extension=opcache.so +opcache.enable=1 +opcache.enable_cli=1 +opcache.fast_shutdown=1 +opcache.memory_consumption= +opcache.interned_strings_buffer=16 +opcache.max_accelerated_files=10000 +opcache.revalidate_freq=60 diff --git a/piwik/rootfs/usr/local/bin/run.sh b/piwik/rootfs/usr/local/bin/run.sh new file mode 100644 index 0000000..887825e --- /dev/null +++ b/piwik/rootfs/usr/local/bin/run.sh @@ -0,0 +1,13 @@ +#!/bin/sh +sed -i -e "s//$UPLOAD_MAX_SIZE/g" /nginx/conf/nginx.conf /php/etc/php-fpm.conf \ + -e "s//$MEMORY_LIMIT/g" /php/etc/php-fpm.conf \ + -e "s//$OPCACHE_MEM_SIZE/g" /php/conf.d/opcache.ini + +if [ ! -f /config/config.ini.php ]; then + cp /piwik/config/config.ini.php /config/config.ini.php +fi + +ln -s /config/config.ini.php /piwik/config/config.ini.php +mv piwik fix && mv fix piwik # fix strange bug +chown -R $UID:$GID /piwik /config /var/log /php /nginx /tmp /usr/share/GeoIP /etc/s6.d +exec su-exec $UID:$GID /bin/s6-svscan /etc/s6.d diff --git a/piwik/run.sh b/piwik/run.sh deleted file mode 100644 index 8c3ae7b..0000000 --- a/piwik/run.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -if [ ! -f /config/config.ini.php ]; then - cp /piwik/config/config.ini.php /config/config.ini.php -fi - -ln -s /config/config.ini.php /piwik/config/config.ini.php -mv piwik fix && mv fix piwik # fix strange bug -chown -R $UID:$GID /piwik /config /var/log /etc/nginx /etc/php7 /var/lib/nginx /tmp /etc/s6.d -exec su-exec $UID:$GID /bin/s6-svscan /etc/s6.d diff --git a/piwik/s6.d/.s6-svscan/finish b/piwik/s6.d/.s6-svscan/finish deleted file mode 100644 index c52d3c2..0000000 --- a/piwik/s6.d/.s6-svscan/finish +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exit 0 diff --git a/piwik/s6.d/nginx/run b/piwik/s6.d/nginx/run deleted file mode 100644 index eaf8049..0000000 --- a/piwik/s6.d/nginx/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec nginx diff --git a/piwik/s6.d/php/run b/piwik/s6.d/php/run deleted file mode 100644 index e238021..0000000 --- a/piwik/s6.d/php/run +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -exec php-fpm7