From 3c2f4b52e176fee88a848a273fd78f02494d6016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Br=C3=BCckner?= Date: Wed, 16 Aug 2017 17:21:07 +0200 Subject: Use custom Dockerfiles instead of mounting files for remote docker #104 --- .../with-nginx-proxy/apache/app/Dockerfile | 4 + .../with-nginx-proxy/apache/app/autoconfig.php | 10 ++ .../with-nginx-proxy/apache/app/redis.php | 11 +++ .../with-nginx-proxy/apache/caching.php | 11 --- .../docker-compose/with-nginx-proxy/apache/db.env | 3 + .../with-nginx-proxy/apache/docker-compose.yml | 12 +-- .../with-nginx-proxy/apache/proxy/Dockerfile | 3 + .../with-nginx-proxy/apache/proxy/uploadsize.conf | 1 + .../with-nginx-proxy/apache/uploadsize.conf | 1 - .../with-nginx-proxy/fpm/app/Dockerfile | 4 + .../with-nginx-proxy/fpm/app/autoconfig.php | 10 ++ .../with-nginx-proxy/fpm/app/redis.php | 11 +++ .../with-nginx-proxy/fpm/caching.php | 11 --- .../docker-compose/with-nginx-proxy/fpm/db.env | 3 + .../with-nginx-proxy/fpm/docker-compose.yml | 17 ++-- .../docker-compose/with-nginx-proxy/fpm/nginx.conf | 110 --------------------- .../with-nginx-proxy/fpm/proxy/Dockerfile | 3 + .../with-nginx-proxy/fpm/proxy/uploadsize.conf | 1 + .../with-nginx-proxy/fpm/uploadsize.conf | 1 - .../with-nginx-proxy/fpm/web/Dockerfile | 3 + .../with-nginx-proxy/fpm/web/nginx.conf | 110 +++++++++++++++++++++ 21 files changed, 191 insertions(+), 149 deletions(-) create mode 100644 .examples/docker-compose/with-nginx-proxy/apache/app/Dockerfile create mode 100644 .examples/docker-compose/with-nginx-proxy/apache/app/autoconfig.php create mode 100644 .examples/docker-compose/with-nginx-proxy/apache/app/redis.php delete mode 100644 .examples/docker-compose/with-nginx-proxy/apache/caching.php create mode 100644 .examples/docker-compose/with-nginx-proxy/apache/db.env create mode 100644 .examples/docker-compose/with-nginx-proxy/apache/proxy/Dockerfile create mode 100644 .examples/docker-compose/with-nginx-proxy/apache/proxy/uploadsize.conf delete mode 100644 .examples/docker-compose/with-nginx-proxy/apache/uploadsize.conf create mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/app/Dockerfile create mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/app/autoconfig.php create mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/app/redis.php delete mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/caching.php create mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/db.env delete mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/nginx.conf create mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/proxy/Dockerfile create mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/proxy/uploadsize.conf delete mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/uploadsize.conf create mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/web/Dockerfile create mode 100644 .examples/docker-compose/with-nginx-proxy/fpm/web/nginx.conf diff --git a/.examples/docker-compose/with-nginx-proxy/apache/app/Dockerfile b/.examples/docker-compose/with-nginx-proxy/apache/app/Dockerfile new file mode 100644 index 00000000..2d54bc41 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/apache/app/Dockerfile @@ -0,0 +1,4 @@ +FROM nextcloud:apache + +COPY autoconfig.php /usr/src/nextcloud/config/autoconfig.php +COPY redis.php /usr/src/nextcloud/config/redis.php diff --git a/.examples/docker-compose/with-nginx-proxy/apache/app/autoconfig.php b/.examples/docker-compose/with-nginx-proxy/apache/app/autoconfig.php new file mode 100644 index 00000000..ea7004e9 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/apache/app/autoconfig.php @@ -0,0 +1,10 @@ + '/var/www/html/data', + 'dbtype' => 'mysql', + 'dbname' => getenv('MYSQL_DATABASE'), + 'dbuser' => getenv('MYSQL_USER'), + 'dbpass' => getenv('MYSQL_PASSWORD'), + 'dbhost' => 'db', + 'dbtableprefix' => '', +); diff --git a/.examples/docker-compose/with-nginx-proxy/apache/app/redis.php b/.examples/docker-compose/with-nginx-proxy/apache/app/redis.php new file mode 100644 index 00000000..9f8b5d2b --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/apache/app/redis.php @@ -0,0 +1,11 @@ + '\\OC\\Memcache\\Redis', + 'filelocking.enabled' => 'true', + 'redis' => + array ( + 'host' => 'redis', + 'port' => 6379, + ), +); +?> diff --git a/.examples/docker-compose/with-nginx-proxy/apache/caching.php b/.examples/docker-compose/with-nginx-proxy/apache/caching.php deleted file mode 100644 index 9f8b5d2b..00000000 --- a/.examples/docker-compose/with-nginx-proxy/apache/caching.php +++ /dev/null @@ -1,11 +0,0 @@ - '\\OC\\Memcache\\Redis', - 'filelocking.enabled' => 'true', - 'redis' => - array ( - 'host' => 'redis', - 'port' => 6379, - ), -); -?> diff --git a/.examples/docker-compose/with-nginx-proxy/apache/db.env b/.examples/docker-compose/with-nginx-proxy/apache/db.env new file mode 100644 index 00000000..a4366057 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/apache/db.env @@ -0,0 +1,3 @@ +MYSQL_PASSWORD= +MYSQL_DATABASE=nextcloud +MYSQL_USER=nextcloud diff --git a/.examples/docker-compose/with-nginx-proxy/apache/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/apache/docker-compose.yml index a186b95b..ab550245 100644 --- a/.examples/docker-compose/with-nginx-proxy/apache/docker-compose.yml +++ b/.examples/docker-compose/with-nginx-proxy/apache/docker-compose.yml @@ -13,7 +13,7 @@ networks: services: proxy: - image: jwilder/nginx-proxy + build: proxy ports: - 80:80 - 443:443 @@ -23,7 +23,6 @@ services: - html:/usr/share/nginx/html - certs:/etc/nginx/certs:ro - /var/run/docker.sock:/tmp/docker.sock:ro - - ./uploadsize.conf:/etc/nginx/conf.d/uploadsize.conf:ro networks: - proxy-tier labels: @@ -43,9 +42,11 @@ services: restart: always app: - image: nextcloud:apache + build: app volumes: - nextcloud:/var/www/html + env_file: + - db.env environment: - VIRTUAL_HOST= - LETSENCRYPT_HOST= @@ -61,9 +62,8 @@ services: - db:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD= - - MYSQL_DATABASE=nextcloud - - MYSQL_USER=nextcloud - - MYSQL_PASSWORD= + env_file: + - db.env restart: always redis: diff --git a/.examples/docker-compose/with-nginx-proxy/apache/proxy/Dockerfile b/.examples/docker-compose/with-nginx-proxy/apache/proxy/Dockerfile new file mode 100644 index 00000000..242c84e1 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/apache/proxy/Dockerfile @@ -0,0 +1,3 @@ +FROM jwilder/nginx-proxy:alpine + +COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf diff --git a/.examples/docker-compose/with-nginx-proxy/apache/proxy/uploadsize.conf b/.examples/docker-compose/with-nginx-proxy/apache/proxy/uploadsize.conf new file mode 100644 index 00000000..8c1bc580 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/apache/proxy/uploadsize.conf @@ -0,0 +1 @@ +client_max_body_size 10g; diff --git a/.examples/docker-compose/with-nginx-proxy/apache/uploadsize.conf b/.examples/docker-compose/with-nginx-proxy/apache/uploadsize.conf deleted file mode 100644 index 8c1bc580..00000000 --- a/.examples/docker-compose/with-nginx-proxy/apache/uploadsize.conf +++ /dev/null @@ -1 +0,0 @@ -client_max_body_size 10g; diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/app/Dockerfile b/.examples/docker-compose/with-nginx-proxy/fpm/app/Dockerfile new file mode 100644 index 00000000..dfd3c8c8 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/fpm/app/Dockerfile @@ -0,0 +1,4 @@ +FROM nextcloud:fpm + +COPY autoconfig.php /usr/src/nextcloud/config/autoconfig.php +COPY redis.php /usr/src/nextcloud/config/redis.php diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/app/autoconfig.php b/.examples/docker-compose/with-nginx-proxy/fpm/app/autoconfig.php new file mode 100644 index 00000000..ea7004e9 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/fpm/app/autoconfig.php @@ -0,0 +1,10 @@ + '/var/www/html/data', + 'dbtype' => 'mysql', + 'dbname' => getenv('MYSQL_DATABASE'), + 'dbuser' => getenv('MYSQL_USER'), + 'dbpass' => getenv('MYSQL_PASSWORD'), + 'dbhost' => 'db', + 'dbtableprefix' => '', +); diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/app/redis.php b/.examples/docker-compose/with-nginx-proxy/fpm/app/redis.php new file mode 100644 index 00000000..9f8b5d2b --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/fpm/app/redis.php @@ -0,0 +1,11 @@ + '\\OC\\Memcache\\Redis', + 'filelocking.enabled' => 'true', + 'redis' => + array ( + 'host' => 'redis', + 'port' => 6379, + ), +); +?> diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/caching.php b/.examples/docker-compose/with-nginx-proxy/fpm/caching.php deleted file mode 100644 index 9f8b5d2b..00000000 --- a/.examples/docker-compose/with-nginx-proxy/fpm/caching.php +++ /dev/null @@ -1,11 +0,0 @@ - '\\OC\\Memcache\\Redis', - 'filelocking.enabled' => 'true', - 'redis' => - array ( - 'host' => 'redis', - 'port' => 6379, - ), -); -?> diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/db.env b/.examples/docker-compose/with-nginx-proxy/fpm/db.env new file mode 100644 index 00000000..a4366057 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/fpm/db.env @@ -0,0 +1,3 @@ +MYSQL_PASSWORD= +MYSQL_DATABASE=nextcloud +MYSQL_USER=nextcloud diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/fpm/docker-compose.yml index 756ebcdb..bbe5ec32 100644 --- a/.examples/docker-compose/with-nginx-proxy/fpm/docker-compose.yml +++ b/.examples/docker-compose/with-nginx-proxy/fpm/docker-compose.yml @@ -13,7 +13,7 @@ networks: services: proxy: - image: jwilder/nginx-proxy + build: proxy ports: - 80:80 - 443:443 @@ -23,7 +23,6 @@ services: - html:/usr/share/nginx/html - certs:/etc/nginx/certs:ro - /var/run/docker.sock:/tmp/docker.sock:ro - - ./uploadsize.conf:/etc/nginx/conf.d/uploadsize.conf:ro networks: - proxy-tier labels: @@ -43,9 +42,8 @@ services: restart: always web: - image: nginx + build: web volumes: - - ./nginx.conf:/etc/nginx/nginx.conf:ro - nextcloud:/var/www/html environment: - VIRTUAL_HOST= @@ -57,7 +55,9 @@ services: restart: always app: - image: nextcloud:fpm + build: app + env_file: + - db.env volumes: - nextcloud:/var/www/html restart: always @@ -66,17 +66,16 @@ services: image: mariadb volumes: - db:/var/lib/mysql + env_file: + - db.env environment: - MYSQL_ROOT_PASSWORD= - - MYSQL_DATABASE=nextcloud - - MYSQL_USER=nextcloud - - MYSQL_PASSWORD= restart: always redis: image: redis restart: always - + collabora: image: collabora/code cap_add: diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/nginx.conf b/.examples/docker-compose/with-nginx-proxy/fpm/nginx.conf deleted file mode 100644 index 40b0975a..00000000 --- a/.examples/docker-compose/with-nginx-proxy/fpm/nginx.conf +++ /dev/null @@ -1,110 +0,0 @@ -user www-data; - -events { - worker_connections 768; -} - -http { - upstream backend { - server app:9000; - } - include /etc/nginx/mime.types; - default_type application/octet-stream; - - server { - listen 80; - - # Add headers to serve security related headers - add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; - add_header X-Content-Type-Options nosniff; - add_header X-XSS-Protection "1; mode=block"; - add_header X-Robots-Tag none; - add_header X-Download-Options noopen; - add_header X-Permitted-Cross-Domain-Policies none; - - root /var/www/html; - client_max_body_size 10G; # 0=unlimited - set max upload size - fastcgi_buffers 64 4K; - - gzip off; - - index index.php; - error_page 403 /core/templates/403.php; - error_page 404 /core/templates/404.php; - - rewrite ^/.well-known/carddav /remote.php/dav/ permanent; - rewrite ^/.well-known/caldav /remote.php/dav/ permanent; - - location = /robots.txt { - allow all; - log_not_found off; - access_log off; - } - - location ~ ^/(build|tests|config|lib|3rdparty|templates|data)/ { - deny all; - } - - location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { - deny all; - } - - location / { - rewrite ^/remote/(.*) /remote.php last; - rewrite ^(/core/doc/[^\/]+/)$ $1/index.html; - try_files $uri $uri/ =404; - } - - location ~ \.php(?:$|/) { - fastcgi_split_path_info ^(.+\.php)(/.+)$; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param HTTPS on; - fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice - fastcgi_pass backend; - fastcgi_intercept_errors on; - } - - # Adding the cache control header for js and css files - # Make sure it is BELOW the location ~ \.php(?:$|/) { block - location ~* \.(?:css|js)$ { - add_header Cache-Control "public, max-age=7200"; - # Add headers to serve security related headers - add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; - add_header X-Content-Type-Options nosniff; - add_header X-Frame-Options "SAMEORIGIN"; - add_header X-XSS-Protection "1; mode=block"; - add_header X-Robots-Tag none; - add_header X-Download-Options noopen; - add_header X-Permitted-Cross-Domain-Policies none; - # Optional: Don't log access to assets - access_log off; - } - - # Optional: Don't log access to other assets - location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ { - access_log off; - } - - # collabora static files - location ^~ /loleaflet { - proxy_pass https://collabora:9980; - proxy_set_header Host $http_host; - } - - # collabora WOPI discovery URL - location ^~ /hosting/discovery { - proxy_pass https://collabora:9980; - proxy_set_header Host $http_host; - } - - # collabora websockets, download, presentation and image upload - location ^~ /lool { - proxy_pass https://collabora:9980; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $http_host; - } - } -} diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/proxy/Dockerfile b/.examples/docker-compose/with-nginx-proxy/fpm/proxy/Dockerfile new file mode 100644 index 00000000..242c84e1 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/fpm/proxy/Dockerfile @@ -0,0 +1,3 @@ +FROM jwilder/nginx-proxy:alpine + +COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/proxy/uploadsize.conf b/.examples/docker-compose/with-nginx-proxy/fpm/proxy/uploadsize.conf new file mode 100644 index 00000000..8c1bc580 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/fpm/proxy/uploadsize.conf @@ -0,0 +1 @@ +client_max_body_size 10g; diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/uploadsize.conf b/.examples/docker-compose/with-nginx-proxy/fpm/uploadsize.conf deleted file mode 100644 index 8c1bc580..00000000 --- a/.examples/docker-compose/with-nginx-proxy/fpm/uploadsize.conf +++ /dev/null @@ -1 +0,0 @@ -client_max_body_size 10g; diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/web/Dockerfile b/.examples/docker-compose/with-nginx-proxy/fpm/web/Dockerfile new file mode 100644 index 00000000..d6eac3e8 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/fpm/web/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx + +COPY nginx.conf /etc/nginx/nginx.conf diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/web/nginx.conf b/.examples/docker-compose/with-nginx-proxy/fpm/web/nginx.conf new file mode 100644 index 00000000..40b0975a --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/fpm/web/nginx.conf @@ -0,0 +1,110 @@ +user www-data; + +events { + worker_connections 768; +} + +http { + upstream backend { + server app:9000; + } + include /etc/nginx/mime.types; + default_type application/octet-stream; + + server { + listen 80; + + # Add headers to serve security related headers + add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Robots-Tag none; + add_header X-Download-Options noopen; + add_header X-Permitted-Cross-Domain-Policies none; + + root /var/www/html; + client_max_body_size 10G; # 0=unlimited - set max upload size + fastcgi_buffers 64 4K; + + gzip off; + + index index.php; + error_page 403 /core/templates/403.php; + error_page 404 /core/templates/404.php; + + rewrite ^/.well-known/carddav /remote.php/dav/ permanent; + rewrite ^/.well-known/caldav /remote.php/dav/ permanent; + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location ~ ^/(build|tests|config|lib|3rdparty|templates|data)/ { + deny all; + } + + location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { + deny all; + } + + location / { + rewrite ^/remote/(.*) /remote.php last; + rewrite ^(/core/doc/[^\/]+/)$ $1/index.html; + try_files $uri $uri/ =404; + } + + location ~ \.php(?:$|/) { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param HTTPS on; + fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice + fastcgi_pass backend; + fastcgi_intercept_errors on; + } + + # Adding the cache control header for js and css files + # Make sure it is BELOW the location ~ \.php(?:$|/) { block + location ~* \.(?:css|js)$ { + add_header Cache-Control "public, max-age=7200"; + # Add headers to serve security related headers + add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; + add_header X-Content-Type-Options nosniff; + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Robots-Tag none; + add_header X-Download-Options noopen; + add_header X-Permitted-Cross-Domain-Policies none; + # Optional: Don't log access to assets + access_log off; + } + + # Optional: Don't log access to other assets + location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ { + access_log off; + } + + # collabora static files + location ^~ /loleaflet { + proxy_pass https://collabora:9980; + proxy_set_header Host $http_host; + } + + # collabora WOPI discovery URL + location ^~ /hosting/discovery { + proxy_pass https://collabora:9980; + proxy_set_header Host $http_host; + } + + # collabora websockets, download, presentation and image upload + location ^~ /lool { + proxy_pass https://collabora:9980; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $http_host; + } + } +} -- cgit v1.2.3