Skip to content

Commit

Permalink
Merge pull request #157 from J0WI/compose
Browse files Browse the repository at this point in the history
Modernize docker-compose.yml
  • Loading branch information
J0WI authored Jun 27, 2019
2 parents 53f0171 + cf75747 commit 5268c9f
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 40 deletions.
3 changes: 3 additions & 0 deletions .examples/apache/db.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MYSQL_PASSWORD=
MYSQL_DATABASE=matomo
MYSQL_USER=matomo
37 changes: 22 additions & 15 deletions .examples/apache/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
version: "3"

services:
db:
image: mariadb
command: --max-allowed-packet=64MB
restart: always
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=
env_file:
- ./db.env

app:
image: matomo:3.5-apache
image: matomo
restart: always
links:
- db
volumes:
- "./config:/var/www/html/config:rw"
- "./logs:/var/www/html/logs"
# - ./config:/var/www/html/config
# - ./logs:/var/www/html/logs
- matomo:/var/www/html
environment:
- "VIRTUAL_HOST=CHANGE_ME"
- MYSQL_HOST=db
- VIRTUAL_HOST=
env_file:
- ./db.env
ports:
- "80:80"
- 8080:80

volumes:
db:
image: mariadb:latest
volumes:
- "./mysql/runtime2:/var/lib/mysql"
environment:
- "MYSQL_DATABASE=db"
- "MYSQL_ROOT_PASSWORD=CHANGE_ME"
- "MYSQL_USER=app"
- "MYSQL_PASSWORD=CHANGE_ME"
matomo:
3 changes: 3 additions & 0 deletions .examples/nginx/db.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MYSQL_PASSWORD=
MYSQL_DATABASE=matomo
MYSQL_USER=matomo
65 changes: 40 additions & 25 deletions .examples/nginx/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
db:
image: mariadb:latest
volumes:
- ./mysql/runtime2:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD
app:
image: matomo:fpm
links:
- db
volumes:
- ./config:/var/www/html/config:rw
- /home/your-logs-folder:/var/www/html/logs
env_file:
- ./matomo.env
web:
image: nginx:latest
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
links:
- app
volumes_from:
- app
environment:
- VIRTUAL_HOST
version: '3'

services:
db:
image: mariadb
command: --max-allowed-packet=64MB
restart: always
volumes:
- db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=
env_file:
- ./db.env

app:
image: matomo:fpm-alpine
restart: always
links:
- db
volumes:
# - ./config:/var/www/html/config:rw
# - ./logs:/var/www/html/logs
- matomo:/var/www/html
environment:
- MYSQL_HOST=db
env_file:
- ./db.env

web:
image: nginx:alpine
restart: always
volumes:
- matomo:/var/www/html:ro
# see https://github.com/matomo-org/matomo-nginx
- ./matomo.conf:/etc/nginx/conf.d/default.conf:ro
ports:
- 8080:80

volumes:
db:
matomo:
69 changes: 69 additions & 0 deletions .examples/nginx/matomo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
upstream php-handler {
server app:9000;
}

server {
listen 80;

add_header Referrer-Policy origin; # make sure outgoing links don't show the URL to the Matomo instance
root /var/www/html; # replace with path to your matomo instance
index index.php;
try_files $uri $uri/ =404;

## only allow accessing the following php files
location ~ ^/(index|matomo|piwik|js/index|plugins/HeatmapSessionRecording/configs).php {
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;

# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;

include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTP_PROXY ""; # prohibit httpoxy: https://httpoxy.org/
fastcgi_pass php-handler;
}

## deny access to all other .php files
location ~* ^.+\.php$ {
deny all;
return 403;
}

## disable all access to the following directories
location ~ /(config|tmp|core|lang) {
deny all;
return 403; # replace with 404 to not show these directories exist
}
location ~ /\.ht {
deny all;
return 403;
}

location ~ js/container_.*_preview\.js$ {
expires off;
add_header Cache-Control 'private, no-cache, no-store';
}

location ~ \.(gif|ico|jpg|png|svg|js|css|htm|html|mp3|mp4|wav|ogg|avi|ttf|eot|woff|woff2|json)$ {
allow all;
## Cache images,CSS,JS and webfonts for an hour
## Increasing the duration may improve the load-time, but may cause old files to show after an Matomo upgrade
expires 1h;
add_header Pragma public;
add_header Cache-Control "public";
}

location ~ /(libs|vendor|plugins|misc/user) {
deny all;
return 403;
}

## properly display textfiles in root directory
location ~/(.*\.md|LEGALNOTICE|LICENSE) {
default_type text/plain;
}
}

# vim: filetype=nginx

0 comments on commit 5268c9f

Please sign in to comment.