From c324114b7a0f1d31ef089371f2e26692a922443c Mon Sep 17 00:00:00 2001 From: Tim Bracken Date: Tue, 16 Aug 2016 15:08:27 -0400 Subject: [PATCH 1/5] Add drupal 8 example to make laradock framework agnostic. --- nginx/sites/framework-examples/drupal_8.conf | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 nginx/sites/framework-examples/drupal_8.conf diff --git a/nginx/sites/framework-examples/drupal_8.conf b/nginx/sites/framework-examples/drupal_8.conf new file mode 100644 index 0000000..30ec958 --- /dev/null +++ b/nginx/sites/framework-examples/drupal_8.conf @@ -0,0 +1,31 @@ +server { + listen 80; + listen [::]:80; + + server_name site_a.dev; + root /var/www/site_a; + index index.php; + + + location / { + try_files $uri $uri/ /index.php?q=$uri&$args; + } + + error_page 404 /404.html; + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /var/www/site_a; + } + + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + if (!-f $document_root$fastcgi_script_name) { + return 404; + } + + fastcgi_pass php-upstream; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} \ No newline at end of file From 95ef5e1e70b419f3cd8ba9f509dac28172c852eb Mon Sep 17 00:00:00 2001 From: Tim Bracken Date: Tue, 16 Aug 2016 15:13:58 -0400 Subject: [PATCH 2/5] Add Drush and Opcache to laradock because they are needed for drupal development. --- php-fpm/Dockerfile-56 | 6 ++++++ php-fpm/Dockerfile-70 | 6 ++++++ workspace/Dockerfile | 14 ++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index 75daf66..f1b8bd7 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -89,6 +89,12 @@ RUN if [ ${INSTALL_MEMCACHED} = true ]; then \ docker-php-ext-enable memcached \ ;fi +##################################### +# Opcache: +##################################### +RUN docker-php-ext-install opcache +RUN docker-php-ext-enable opcache + # #-------------------------------------------------------------------------- diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index ca129bb..a4766bd 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -100,6 +100,12 @@ RUN if [ ${INSTALL_MEMCACHED} = true ]; then \ && docker-php-ext-enable memcached \ ;fi +##################################### +# Opcache: +##################################### +RUN docker-php-ext-install opcache +RUN docker-php-ext-enable opcache + # #-------------------------------------------------------------------------- diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 31d47ec..7caf004 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -97,6 +97,20 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \ composer global install \ ;fi +##################################### +# Drush: +##################################### +ENV DRUSH_VERSION 8.1.2 + +# Install Drush 8 with the phar file. +USER root +RUN curl -fsSL -o /usr/local/bin/drush "https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar" && \ + chmod +x /usr/local/bin/drush + +#Check if drush works for the laradock user +USER laradock +RUN drush core-status + ##################################### # Node / NVM: ##################################### From 928451ae888212c0c94b4360d8834b8770b9799b Mon Sep 17 00:00:00 2001 From: Tim Bracken Date: Tue, 16 Aug 2016 16:32:59 -0400 Subject: [PATCH 3/5] This is a better Drupal nginx config. Built from a combination of contributions from here: https://groups.drupal.org/node/305633 https://www.nginx.com/resources/wiki/start/topics/recipes/drupal/ --- nginx/sites/framework-examples/drupal_8.conf | 56 +++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/nginx/sites/framework-examples/drupal_8.conf b/nginx/sites/framework-examples/drupal_8.conf index 30ec958..a5d398a 100644 --- a/nginx/sites/framework-examples/drupal_8.conf +++ b/nginx/sites/framework-examples/drupal_8.conf @@ -1,28 +1,56 @@ server { - listen 80; + listen 80; listen [::]:80; - server_name site_a.dev; - root /var/www/site_a; - index index.php; + #domain name + server_name drupal8.dev; + #file document root. This has to match one of the volumes in docer-composer.yml + root /var/www/drupal8; + + # This is the full path to your index file + index index.php index.html index.htm; + + + ## serve imagecache files directly or redirect to drupal if they do not exist. + location ~* files/styles { + access_log off; + expires 30d; + try_files $uri @drupal; + } + + ## serve imagecache files directly or redirect to drupal if they do not exist. + location ~* ^.+.(xsl|xml)$ { + access_log off; + expires 1d; + try_files $uri @drupal; + } + + ## Images and static content is treated different + location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ { + access_log off; + expires 30d; + } location / { - try_files $uri $uri/ /index.php?q=$uri&$args; + index index.php; + # This is cool because no php is touched for static content + try_files $uri $uri/ @rewrite; + expires max; } - error_page 404 /404.html; - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /var/www/site_a; + location @drupal { + rewrite ^/(.*)$ /index.php?q=$1 last; } - location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - if (!-f $document_root$fastcgi_script_name) { - return 404; - } + location @rewrite { + # Some modules enforce no slash (/) at the end of the URL + # Else this rewrite block wouldn't be needed (GlobalRedirect) + rewrite ^/(.*)$ /index.php?q=$1; + } + + location ~ .php$ { fastcgi_pass php-upstream; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; From cfc81fca643b028363684481880c6f98486059eb Mon Sep 17 00:00:00 2001 From: Tim Bracken Date: Tue, 16 Aug 2016 17:51:41 -0400 Subject: [PATCH 4/5] Allow for config of crush and opcache in the main docker file --- docker-compose.yml | 2 ++ php-fpm/Dockerfile-56 | 8 ++++++-- php-fpm/Dockerfile-70 | 9 +++++++-- workspace/Dockerfile | 17 ++++++++++------- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5013507..355d458 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: - INSTALL_MONGO=false - INSTALL_XDEBUG=false - INSTALL_NODE=false + - INSTALL_DRUSH=false - COMPOSER_GLOBAL_INSTALL=false - PUID=1000 - PGID=1000 @@ -33,6 +34,7 @@ services: - INSTALL_XDEBUG=false - INSTALL_ZIP_ARCHIVE=false - INSTALL_MEMCACHED=false + - INSTALL_OPCACHE=false dockerfile: Dockerfile-70 volumes_from: - volumes_source diff --git a/php-fpm/Dockerfile-56 b/php-fpm/Dockerfile-56 index f1b8bd7..62ac6f9 100644 --- a/php-fpm/Dockerfile-56 +++ b/php-fpm/Dockerfile-56 @@ -92,8 +92,12 @@ RUN if [ ${INSTALL_MEMCACHED} = true ]; then \ ##################################### # Opcache: ##################################### -RUN docker-php-ext-install opcache -RUN docker-php-ext-enable opcache +ARG INSTALL_OPCACHE=true +ENV INSTALL_OPCACHE ${INSTALL_OPCACHE} +RUN if [ ${INSTALL_OPCACHE} = true ]; then \ + docker-php-ext-install opcache && \ + docker-php-ext-enable opcache \ +;fi # diff --git a/php-fpm/Dockerfile-70 b/php-fpm/Dockerfile-70 index a4766bd..8c296ce 100644 --- a/php-fpm/Dockerfile-70 +++ b/php-fpm/Dockerfile-70 @@ -103,8 +103,13 @@ RUN if [ ${INSTALL_MEMCACHED} = true ]; then \ ##################################### # Opcache: ##################################### -RUN docker-php-ext-install opcache -RUN docker-php-ext-enable opcache +ARG INSTALL_OPCACHE=true +ENV INSTALL_OPCACHE ${INSTALL_OPCACHE} +RUN if [ ${INSTALL_OPCACHE} = true ]; then \ + docker-php-ext-install opcache && \ + docker-php-ext-enable opcache \ +;fi + # diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 7caf004..1f728bd 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -37,6 +37,7 @@ MAINTAINER Mahmoud Zalt # - INSTALL_MONGO= false # - COMPOSER_GLOBAL_INSTALL= false # - INSTALL_NODE= false +# - INSTALL_drush= false # ##################################### @@ -100,16 +101,18 @@ RUN if [ ${COMPOSER_GLOBAL_INSTALL} = true ]; then \ ##################################### # Drush: ##################################### -ENV DRUSH_VERSION 8.1.2 - -# Install Drush 8 with the phar file. USER root -RUN curl -fsSL -o /usr/local/bin/drush "https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar" && \ - chmod +x /usr/local/bin/drush +ENV DRUSH_VERSION 8.1.2 +ARG INSTALL_DRUSH=true +ENV INSTALL_DRUSH ${INSTALL_DRUSH} +RUN if [ ${INSTALL_DRUSH} = true ]; then \ + # Install Drush 8 with the phar file. + curl -fsSL -o /usr/local/bin/drush https://github.com/drush-ops/drush/releases/download/$DRUSH_VERSION/drush.phar | bash && \ + chmod +x /usr/local/bin/drush && \ + drush core-status \ +;fi -#Check if drush works for the laradock user USER laradock -RUN drush core-status ##################################### # Node / NVM: From b648f1ca58ee2cf292260a466e1d4199d03395af Mon Sep 17 00:00:00 2001 From: Tim Bracken Date: Tue, 16 Aug 2016 17:53:15 -0400 Subject: [PATCH 5/5] Fix typo --- workspace/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 1f728bd..e5338f6 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -37,7 +37,7 @@ MAINTAINER Mahmoud Zalt # - INSTALL_MONGO= false # - COMPOSER_GLOBAL_INSTALL= false # - INSTALL_NODE= false -# - INSTALL_drush= false +# - INSTALL_DRUSH= false # #####################################