Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
First commit
  • Loading branch information
pierreozoux committed Sep 23, 2015
0 parents commit e6538b9
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env
@@ -0,0 +1,5 @@
MYSQL_ROOT_PASSWORD=
MAIL_HOST=
MAIL_PORT=
MAIL_USER=
MAIL_PASS=
5 changes: 5 additions & 0 deletions BACKUP
@@ -0,0 +1,5 @@
#!/bin/bash -eux
URL=${PWD##*/}
db_container_name=`echo ${URL}_db_1 | sed "s/\.//g" | sed "s/-//g"`; \

docker exec $db_container_name bash -c 'mysqldump --all-databases --events -uroot -p$MYSQL_ROOT_PASSWORD' > ./mysql/dump.sql
42 changes: 42 additions & 0 deletions Dockerfile
@@ -0,0 +1,42 @@
FROM php:5.6-fpm

RUN apt-get update && apt-get install -y \
cron \
libjpeg-dev \
libfreetype6-dev \
libgeoip-dev \
libpng12-dev \
ssmtp \
zip \
&& rm -rf /var/lib/apt/lists/*

RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys 0xb5dbd5925590a237

RUN docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr \
&& docker-php-ext-install gd mbstring mysql pdo_mysql zip

RUN pecl install APCu-beta geoip

ENV PIWIK_VERSION 2.14.3

VOLUME /var/www/html/

RUN curl -fsSL -o piwik.tar.gz \
"https://builds.piwik.org/piwik-${PIWIK_VERSION}.tar.gz" \
&& curl -fsSL -o piwik.tar.gz.asc \
"https://builds.piwik.org/piwik-${PIWIK_VERSION}.tar.gz.asc" \
&& gpg --verify piwik.tar.gz.asc \
&& tar -xzf piwik.tar.gz -C /usr/src/ \
&& rm piwik.tar.gz piwik.tar.gz.asc

COPY php.ini /usr/local/etc/php/php.ini

RUN cd /usr/src/piwik/misc \
&& curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz > GeoLiteCity.dat.gz \
&& gunzip GeoLiteCity.dat.gz \
&& mv GeoLiteCity.dat GeoIPCity.dat

COPY docker-entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
CMD ["php-fpm"]
44 changes: 44 additions & 0 deletions README.md
@@ -0,0 +1,44 @@
# Piwik

Piwik is the leading open-source analytics platform that gives you more than just powerful analytics:
- Free open-source software
- 100% data ownership
- User privacy protection
- User-centric insights
- Customisable and extensible

![logo](https://rawgit.com/piwik/docker-piwik/master/logo.svg)

# How to use this image

The easiest is to use our `docker-compose.yml`.

Make sure you have [docker-compose](http://docs.docker.com/compose/install/) installed. And then:

```
git clone https://github.com/piwik/docker-piwik.git
cd docker-piwik
# edit variables:
vi .env
docker-compose up
```

You can now access your instance on the port 80 of the IP of your machine.

## Accees it from Internet

We recommend the usage of SSL, so the easiest is to modify the `nginx.conf` file.

Once it is done, you can connect to the port of the host by adding this line to `docker-compose.yml`:
```
web:
...
- ports:
- "443:443"
- "80:80"
...
```

## Backup

In order to backup, just run the `./BACKUP` script. And copy all the data to a safe place.
2 changes: 2 additions & 0 deletions crontab
@@ -0,0 +1,2 @@
SHELL=/bin/bash
*/1 * * * * www-data /usr/local/bin/php /var/www/html/console core:archive >> /dev/null 2>&1
33 changes: 33 additions & 0 deletions docker-compose.yml
@@ -0,0 +1,33 @@
db:
image: mysql
volumes:
- ./mysql/runtime:/var/lib/mysql
env_file:
- ./.env
app:
image: piwik
links:
- db
volumes:
- ./config:/var/www/html/config
env_file:
- ./.env
web:
image: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
links:
- app
volumes_from:
- app
ports:
- "80:80"
cron:
image: piwik
command: cron -f
volumes:
- ./crontab:/etc/cron.d/piwik
volumes_from:
- app
links:
- db
23 changes: 23 additions & 0 deletions docker-entrypoint.sh
@@ -0,0 +1,23 @@
#!/bin/bash
set -e

if [ ! -e '/var/www/html/piwik.php' ]; then
tar cf - --one-file-system -C /usr/src/piwik . | tar xf -
chown -R www-data /var/www/html
fi

chfn -f 'Piwik Admin' www-data

cat > /etc/ssmtp/ssmtp.conf << EOF
UseTLS=Yes
UseSTARTTLS=Yes
root=${MAIL_USER}
mailhub=${MAIL_HOST}:${MAIL_PORT}
hostname=${MAIL_USER}
AuthUser=${MAIL_USER}
AuthPass=${MAIL_PASS}
EOF

echo "www-data:${MAIL_USER}:${MAIL_HOST}:${MAIL_PORT}" >> /etc/ssmtp/revaliases

exec "$@"
1 change: 1 addition & 0 deletions license.md
@@ -0,0 +1 @@
View [license information](https://github.com/piwik/piwik/blob/master/LEGALNOTICE) for the software contained in this image.
25 changes: 25 additions & 0 deletions logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions nginx.conf
@@ -0,0 +1,60 @@
user www-data;

events {
worker_connections 768;
}

http {
upstream backend {
server app:9000;
}

include /etc/nginx/mime.types;
default_type application/octet-stream;
gzip on;
gzip_disable "msie6";

server {
listen 80;

root /var/www/html/;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ =404;
}

error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location ~ \.php$ {
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_intercept_errors on;
fastcgi_pass backend;
}
}
}
4 changes: 4 additions & 0 deletions php.ini
@@ -0,0 +1,4 @@
always_populate_raw_post_data=-1
sendmail_path = /usr/sbin/ssmtp -t
extension=geoip.so
geoip.custom_directory=/var/www/html/misc

0 comments on commit e6538b9

Please sign in to comment.