initial commit

This commit is contained in:
Wonderfall
2016-04-11 15:59:32 +02:00
commit 13f2d49927
85 changed files with 4343 additions and 0 deletions

48
piwik/Dockerfile Normal file
View File

@ -0,0 +1,48 @@
FROM alpine:3.3
MAINTAINER Wonderfall <wonderfall@mondedie.fr>
ENV VER=2.16.0 GID=991 UID=991
RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& echo "@commuedge http://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& apk -U add \
nginx \
php-fpm \
php-gd \
php-curl \
php-cli \
php-json \
php-ctype \
php-iconv \
php-zlib \
php-dom \
php-openssl \
php-geoip@testing \
php-mysqli \
php-pdo_mysql \
supervisor \
tini@commuedge \
&& sed -i 's/;always_populate_raw_post_data/always_populate_raw_post_data/g' /etc/php/php.ini \
&& echo 'geoip.custom_directory=/piwik/misc' >> /etc/php/php.ini \
&& rm -f /var/cache/apk/*
RUN wget -qO- http://builds.piwik.org/piwik-$VER.tar.gz | tar xz
RUN wget -q http://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
COPY nginx.conf /etc/nginx/nginx.conf
COPY php-fpm.conf /etc/php/php-fpm.conf
COPY supervisord.conf /usr/local/etc/supervisord.conf
COPY run.sh /usr/local/bin/run.sh
RUN chmod +x /usr/local/bin/run.sh
VOLUME /config
EXPOSE 80
LABEL description "Open web analytics platform" \
piwik "Piwik v$VER"
CMD ["tini","--","run.sh"]

66
piwik/README.md Normal file
View File

@ -0,0 +1,66 @@
## wonderfall/piwik
[![](https://badge.imagelayers.io/wonderfall/analytics:latest.svg)](https://imagelayers.io/?images=wonderfall/analytics:latest 'Get your own badge on imagelayers.io')
![](https://i.goopics.net/m3.png)
#### What is this?
It is a web analytics platform. Piwik respects your privacy and gives you full control over your data.
#### Features
- Based on Alpine Linux 3.3 : lightweight and secure.
- Functional installation. Pull and run.
- Latest Piwik stable.
- nginx stable + php-fpm stable.
- pdo_mysql and mysqli available (mysql server not built-in).
- Latest GeoLite City Database from maxmind.com.
- External + automatic backup of configuration.
#### Environment variables
- **GID** : piwik group id.
- **UID** : piwik user id.
#### Volumes
- **/config** : configuration files
#### Update
Piwik can update itself. It works well. I'm also maintaing this Dockerfile, so if you don't want to do upgrades directly from Piwik, you can recreate the container as well whenever I push an update.
#### Configuration
According to Piwik, everything should be fine running this image. You shoudn't have any difficulties to setup your own instance of Piwik. Your `/config/config.ini.php` overwrites the one (in `/piwik/config`)used by Piwik each time the container is started. Moreover, the old config.ini.php is saved as `/config/config.ini.php.bkp` if you want to revert last changes. This should also guarantee transparency through Piwik's updates.
If you're running Piwik behind a reverse proxy (most likely you do), add this to your `config.ini.php` :
```
[General]
#assume_secure_protocol = 1 #uncomment if you use https
proxy_client_headers[] = HTTP_X_FORWARDED_FOR
proxy_client_headers[] = HTTP_X_REAL_IP
proxy_host_headers[] = HTTP_X_FORWARDED_HOST
```
#### Reverse proxy
https://github.com/Wonderfall/dockerfiles/tree/master/reverse
#### Docker Compose (example)
```
piwik:
image: wonderfall/piwik
links:
- db_piwik:db_piwik
volumes:
- /mnt/docker/piwik/config:/config
environment:
- GID=1000
- UID=1000
db_piwik:
image: mariadb:10
volumes:
- /mnt/docker/piwik/db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=asupersecretpassword
- MYSQL_DATABASE=piwik
- MYSQL_USER=piwik
- MYSQL_PASSWORD=asupersecretpassword
```

97
piwik/nginx.conf Normal file
View File

@ -0,0 +1,97 @@
user piwik;
worker_processes auto;
pid /var/run/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 /var/log/nginx/error.log error;
sendfile on;
keepalive_timeout 15;
keepalive_disable msie6;
keepalive_requests 100;
tcp_nopush on;
tcp_nodelay off;
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 {
listen 80;
root /piwik;
index index.php index.html;
location ~* \.(?:bat|git|ini|sh|svn[^.]*|txt|tpl|xml)$ {
return 404;
}
location ~* \.(jpg|jpeg|gif|css|png|js|map|woff|woff2|ttf|svg|eot)$ {
expires 30d;
access_log off;
}
location = /favicon.ico {
try_files /favicon.ico =204;
}
location ~* ^/(?:README|LICENSE[^.]*|LEGALNOTICE)(?:\.txt)*$ {
return 404;
}
location ~ ^/(vendor|config|tmp|libs|misc) {
deny all;
return 404;
}
location ~* /(.*)\.(?:markdown|md|twig|yaml|yml|ht|htaccess|ini)$ {
deny all;
}
location ~ /\. {
deny all;
}
location / {
try_files $uri /index.php;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
}

15
piwik/php-fpm.conf Normal file
View File

@ -0,0 +1,15 @@
[global]
daemonize = no
[www]
user = piwik
group = piwik
listen = /var/run/php-fpm.sock
listen.owner = piwik
listen.group = piwik
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /

12
piwik/run.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
addgroup -g ${GID} piwik && adduser -h /piwik -s /bin/sh -D -G piwik -u ${UID} piwik
if [ -f /piwik/config/config.ini.php ] && [ ! -f /config/config.ini.php ]; then
cp /piwik/config/config.ini.php /config/config.ini.php
elif [ -f /config/config.ini.php ]; then
mv /piwik/config/config.ini.php /config/config.ini.php.bkp
cp /config/config.ini.php /piwik/config/config.ini.php
fi
chown -R piwik:piwik /piwik /config /var/run/php-fpm.sock /var/lib/nginx /tmp
supervisord -c /usr/local/etc/supervisord.conf

8
piwik/supervisord.conf Normal file
View File

@ -0,0 +1,8 @@
[supervisord]
nodaemon=true
[program:php-fpm]
command=php-fpm
[program:nginx]
command=nginx