Skip to content

Instantly share code, notes, and snippets.

@samayo
Forked from mohamed-el-habib/00_ReadMe.md
Created October 17, 2018 21:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save samayo/92dff31827587380114907056ef75bb7 to your computer and use it in GitHub Desktop.
Save samayo/92dff31827587380114907056ef75bb7 to your computer and use it in GitHub Desktop.
drupal fpm with nginx and mysql

Usage

git clone git://github.com/fd57d8aa59b1574ee7728edf128814d3.git docker-drupal-fpm
cd docker-drupal-fpm
mkdir -p /usr/local/share/dockervolumes/drupal # if you change this folder please update the run.sh
chmod +x run.sh && ./run.sh up
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
root /var/www/html;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
# location ~ \.php$ {
# #root html;
# fastcgi_pass php:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
# include fastcgi_params;
# }
## 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;
}
## Default location
location / {
try_files $uri $uri/ @drupal;
index index.php;
}
location @drupal {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
## Images and static content is treated different
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
expires 30d;
}
## Parse all .php file in the /var/www directory
location ~ .php$ {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
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_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
## Disable viewing .htaccess & .htpassword
location ~ /\.ht {
deny all;
}
}
upstream backend {
server php:9000;
}
nginx:
image: nginx
container_name: drupal_nginx
environment:
- NGINX_PORT=80
ports:
- "80:80"
links:
- php
volumes:
- ./default.conf:/etc/nginx/conf.d/default.conf:ro
volumes_from:
- php:ro
php:
image: drupal:7.43-fpm
container_name: drupal_php-fpm
links:
- db:mysql
volumes:
- ${dockervolume_root}/sites:/var/www/html/sites
- ${dockervolume_root}/private:/var/www/private
- /var/www/html
expose:
- 9000
environment:
- UPLOAD_LIMIT=20M
- MEMORY_LIMIT=128M
- VIRTUAL_HOST=eni-dev1.digitas.fr
db:
image: mysql:5.7.12
env_file:
- ./mysql.credentials.env
volumes:
- ${dockervolume_root}/mysql:/var/lib/mysql
MYSQL_ROOT_PASSWORD=rootpass
MYSQL_DATABASE=drupaldb
MYSQL_USER=drupalusr
MYSQL_PASSWORD=drupalpass
#!/bin/bash
script_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
dockervolume_root="/usr/local/share/dockervolumes/drupal" docker-compose --file $script_dir/docker-compose.yml "$@"
@zar3bski
Copy link

great inspiration. Thanks! Perhaps you should just also include the version of docker-compose (e.g. version: '3.7'), for some parameters like volumes_from do not exist anymore

@samayo
Copy link
Author

samayo commented Jan 23, 2020

Thanks. I didn't think anyone would use it. Feel free to fork and improve it as I haven't used it in a while probably won't in the coming months

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment