From 606cb6dd93bd29466e27079c788c8114b9280354 Mon Sep 17 00:00:00 2001
From: Your Name <you@example.com>
Date: Sun, 7 Jun 2015 19:37:38 +0000
Subject: [PATCH] WIP

---
 dockerfiles/services/mysql/Dockerfile       |  1 +
 dockerfiles/services/piwik/Dockerfile       |  5 +++++
 dockerfiles/services/piwik/startup-piwik.sh | 14 ++++++++++++++
 unit-files/backup-u@.service                |  2 +-
 unit-files/backup@.service                  |  2 +-
 5 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/dockerfiles/services/mysql/Dockerfile b/dockerfiles/services/mysql/Dockerfile
index ac4dba3..c4ed8fe 100644
--- a/dockerfiles/services/mysql/Dockerfile
+++ b/dockerfiles/services/mysql/Dockerfile
@@ -1 +1,2 @@
 FROM tutum/mysql
+
diff --git a/dockerfiles/services/piwik/Dockerfile b/dockerfiles/services/piwik/Dockerfile
index 3d50361..93ca815 100644
--- a/dockerfiles/services/piwik/Dockerfile
+++ b/dockerfiles/services/piwik/Dockerfile
@@ -10,6 +10,11 @@ RUN apt-get update && apt-get install -y \
     curl -O "http://builds.piwik.org/piwik.zip" && \
     unzip piwik.zip && \
     mv /piwik/config /piwik-config && \
+    sed -i 's/;always_populate_raw_post_data = -1/always_populate_raw_post_data=-1/g' /etc/php5/fpm/php.ini && \
+    cd /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 && \
     sed -i 's/# exec CMD/# exec CMD\n\/opt\/startup-piwik.sh/g' /opt/entrypoint.sh
 
 # install nginx piwik config
diff --git a/dockerfiles/services/piwik/startup-piwik.sh b/dockerfiles/services/piwik/startup-piwik.sh
index b7de64e..1b1e3eb 100644
--- a/dockerfiles/services/piwik/startup-piwik.sh
+++ b/dockerfiles/services/piwik/startup-piwik.sh
@@ -237,3 +237,17 @@ Add the following JS-Code to your Site -> don't forget to change the URLs ;)
 <!-- End Piwik Code -->
 EOF
 
+# Put the right MySQL adapter
+if ! grep -q adapter /piwik/config/config.ini.php; then
+  sed -i  '/\[database\]/a adapter=MYSQLI' /piwik/config/config.ini.php
+fi
+
+# Fix IP behind proxy
+if ! grep -q proxy_client_headers /piwik/config/config.ini.php; then
+  sed -i  '/\[General\]/a proxy_client_headers[] = HTTP_X_FORWARDED_FOR' /piwik/config/config.ini.php
+fi
+
+if ! grep -q proxy_host_headers /piwik/config/config.ini.php; then
+  sed -i  '/\[General\]/a proxy_host_headers[] = HTTP_X_FORWARDED_HOST' /piwik/config/config.ini.php
+fi
+
diff --git a/unit-files/backup-u@.service b/unit-files/backup-u@.service
index 15ae63b..cf441e0 100644
--- a/unit-files/backup-u@.service
+++ b/unit-files/backup-u@.service
@@ -20,7 +20,7 @@ ExecStart=/bin/bash -euxc ' \
     --rm \
     --name backup-%i \
     -h backup.container \
-    --cpu-shares=100 \
+    --cpu-shares=40 \
     -v /root:/root \
     -v /data/domains/%i:/backup indiepaas/duplicity \
       --full-if-older-than 1W \
diff --git a/unit-files/backup@.service b/unit-files/backup@.service
index 678fbce..29da134 100644
--- a/unit-files/backup@.service
+++ b/unit-files/backup@.service
@@ -37,7 +37,7 @@ ExecStart=/bin/bash -euxc ' \
   /bin/docker run \
     --rm \
     --name backup-%i \
-    --cpu-shares=100 \
+    --cpu-shares=40 \
     -h backup.container \
     -v /root:/root \
     -v /data/domains/%i:/backup indiepaas/duplicity \
-- 
GitLab