Skip to content

Instantly share code, notes, and snippets.

@lslinnet
Last active June 15, 2016 11:08
Show Gist options
  • Save lslinnet/256ade7cef28962e58ee03759dc8fc7f to your computer and use it in GitHub Desktop.
Save lslinnet/256ade7cef28962e58ee03759dc8fc7f to your computer and use it in GitHub Desktop.
Docker compose setup

Add db mc dblegacy solr01 to etc hosts pointing to 127.0.0.1 for drush to function.

underscores in file names indicates directories. e.g. docker_proxy_acl.vcl -> docker/proxy/acl.vcl

version: '2'
services:
web:
image: reload/drupal-apache-fpm
ports:
- '80:80'
volumes_from:
- webroot
links:
- php:fpm
https:
image: zazukoians/hitch
ports:
- '443:443'
environment:
HITCH_PARAMS: --backend=[web]:80 --frontend=[*]:443
links:
- proxy
proxy:
image: zazukoians/varnish
ports:
- '8080:80'
links:
- web
environment:
VCL_CONFIG: /vcl/custom.vcl
VARNISHD_PARAMS: '-p vcl_dir=/vcl'
volumes:
- './environment-setup/varnish/custom.vcl:/vcl/custom.vcl'
- './docker/proxy/backends.vcl:/vcl/backends.vcl'
- './docker/proxy/acl.vcl:/vcl/acl.vcl'
php:
image: adaptdk/docker-php-fpm-drupal7
ports:
- "9000:9000"
volumes_from:
- webroot
links:
- db
- dblegacy
- mc
- solr:solr01
mc:
image: memcached
ports:
- '11211:11211'
solr:
image: mparker17/solr-search-api-solr
ports:
- '8983:8983'
expose:
- '8983'
logging:
driver: none
db:
image: mariadb:10
ports:
- '3306:3306'
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db
MYSQL_USER: db
MYSQL_PASSWORD: db
volumes:
- './dbdata:/var/lib/mysql'
dblegacy:
image: mariadb:10
ports:
- '3307:3306'
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: db_legacy
MYSQL_USER: db
MYSQL_PASSWORD: db
volumes:
- './dbdata_legacy:/var/lib/mysql'
webroot:
image: tianon/true
volumes:
- './htdocs:/var/www/web:rw'
- './settings/docker.settings.php:/var/www/web/sites/default/settings.php:ro'
vcl 4.0;
acl purge {
"0.0.0.0"/0; # Match anything.
}
vcl 4.0;
# Docker exposes the webserver under the hostname web
backend default {
.host = "web";
.port = "80";
}
vcl 4.0;
include "backends.vcl";
include "acl.vcl";
sub vcl_recv {
# Happens before we check if we have this in cache already.
#
# Typically you clean up the request here, removing cookies you dont need,
# rewriting the request, etc.
# Cachetag support
# Only allow BAN requests from IP addresses in the purge ACL.
if (req.method == "BAN") {
# Same ACL check as above:
if (!client.ip ~ purge) {
return (synth(403, "Not allowed."));
}
# Logic for the ban, using the Purge-Cache-Tags header. For more info
# see https://github.com/geerlingguy/drupal-vm/issues/397.
if (req.http.Purge-Cache-Tags) {
ban("obj.http.Purge-Cache-Tags ~ " + req.http.Purge-Cache-Tags);
}
else {
return (synth(403, "Purge-Cache-Tags header missing."));
}
# Throw a synthetic page so the request won't go to the backend.
return (synth(200, "Ban added."));
}
}
sub vcl_backend_response {
# Happens after we have read the response headers from the backend.
#
# Here you clean the response headers, removing silly Set-Cookie headers
# and other mistakes your backend does.
# Cachetags support
# Set ban-lurker friendly custom headers.
set beresp.http.X-Url = bereq.url;
set beresp.http.X-Host = bereq.http.host;
}
sub vcl_deliver {
# Happens when we have all the pieces we need, and are about to send the
# response to the client.
#
# You can do accounting or modifying the final object here.
# Cachetag support
# Remove ban-lurker friendly custom headers when delivering to client.
unset resp.http.X-Url;
unset resp.http.X-Host;
unset resp.http.Purge-Cache-Tags;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment