Skip to content

Instantly share code, notes, and snippets.

@mohamed-el-habib
Last active April 10, 2020 10:21
Show Gist options
  • Save mohamed-el-habib/fd57d8aa59b1574ee7728edf128814d3 to your computer and use it in GitHub Desktop.
Save mohamed-el-habib/fd57d8aa59b1574ee7728edf128814d3 to your computer and use it in GitHub Desktop.

Revisions

  1. mohamed-el-habib revised this gist Jun 8, 2016. 4 changed files with 10 additions and 5 deletions.
    4 changes: 2 additions & 2 deletions 00_ReadMe.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ## Usage
    git clone git://github.com/[this gist id].git docker-drupal-fpm
    cd docker-nginx-fpm
    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
    3 changes: 2 additions & 1 deletion default.conf
    Original file line number Diff line number Diff line change
    @@ -92,4 +92,5 @@ server {
    }

    upstream backend {
    server php:9000;
    server php:9000;
    }
    4 changes: 2 additions & 2 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,6 @@ php:
    db:
    image: mysql:5.7.12
    env_file:
    - /usr/local/share/dockerconfig/drupal/mysql.credentials.env
    - ./mysql.credentials.env
    volumes:
    - /usr/local/share/dockervolumes/drupal/mysql:/var/lib/mysql
    - ${dockervolume_root}/mysql:/var/lib/mysql
    4 changes: 4 additions & 0 deletions mysql.credentials.env
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    MYSQL_ROOT_PASSWORD=rootpass
    MYSQL_DATABASE=drupaldb
    MYSQL_USER=drupalusr
    MYSQL_PASSWORD=drupalpass
  2. mohamed-el-habib created this gist Jun 8, 2016.
    5 changes: 5 additions & 0 deletions 00_ReadMe.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    ## Usage
    git clone git://github.com/[this gist id].git docker-drupal-fpm
    cd docker-nginx-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
    95 changes: 95 additions & 0 deletions default.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,95 @@
    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;
    34 changes: 34 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    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:
    - /usr/local/share/dockerconfig/drupal/mysql.credentials.env
    volumes:
    - /usr/local/share/dockervolumes/drupal/mysql:/var/lib/mysql
    3 changes: 3 additions & 0 deletions run.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    #!/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 "$@"