-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4bd160
commit e197654
Showing
8 changed files
with
128 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,54 @@ | ||
FROM buildpack-deps:jessie | ||
FROM ubuntu:15.04 | ||
|
||
ENV VARNISH_VERSION 4.0.3-2~jessie | ||
ENV DEBIAN_FRONTEND noninteractive | ||
|
||
RUN apt-get update \ | ||
&& apt-get install apt-transport-https \ | ||
&& curl https://repo.varnish-cache.org/GPG-key.txt | apt-key add - \ | ||
&& echo "deb https://repo.varnish-cache.org/debian/ jessie varnish-4.0" >> /etc/apt/sources.list.d/varnish-cache.list \ | ||
&& apt-get update \ | ||
&& apt-get install -y varnish=$VARNISH_VERSION | ||
# Update apt sources | ||
#RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list | ||
|
||
COPY varnish.vcl /etc/varnish.vcl | ||
# Update the package repository | ||
RUN apt-get -qq update | ||
|
||
CMD ["varnishd", "-F", "-f", "/etc/varnish.vcl"] | ||
# Install base system | ||
RUN apt-get install -y vim git dpkg-dev curl \ | ||
# Varnish build dependencies. | ||
automake autotools-dev libedit-dev libjemalloc-dev libncurses-dev libpcre3-dev libtool pkg-config python-docutils python-sphinx graphviz | ||
|
||
# Build Varnish from source because that's required to install Varnish modules :D | ||
RUN cd /usr/local/src/ && apt-get source varnish && \ | ||
cd varnish-4.0.2 && \ | ||
sh autogen.sh && \ | ||
sh configure && \ | ||
make && \ | ||
make install | ||
|
||
# RUN apt-get install -y build-essential libtool | ||
|
||
# Install Querystring Varnish module | ||
RUN cd /usr/local/src/ && \ | ||
git clone https://github.com/Dridi/libvmod-querystring && \ | ||
cd /usr/local/src/libvmod-querystring && \ | ||
./autogen.sh && \ | ||
./configure VARNISHSRC=/usr/local/src/varnish-4.0.2 && \ | ||
make && \ | ||
make install && \ | ||
make check | ||
|
||
# Varnish shared library installs to obscure location, so make that available via ldconfig. | ||
# This seems awkward, I wonder if there's a way to stipulate putting this shared object file | ||
# in `/usr/lib/`. Granted I know nothing about UNIX folder layout. | ||
RUN ldconfig && ldconfig -n /usr/local/lib/ | ||
|
||
# Make our custom VCLs available on the container | ||
ADD default.vcl /etc/varnish/default.vcl | ||
|
||
# Export environment variables | ||
ENV VARNISH_PORT 80 | ||
|
||
# Expose port 80 | ||
EXPOSE 80 | ||
|
||
ADD start /start | ||
|
||
RUN chmod 0755 /start | ||
|
||
CMD ["/start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# This is an example VCL file for Varnish. | ||
# | ||
# It does not do anything by default, delegating control to the | ||
# builtin VCL. The builtin VCL is called when there is no explicit | ||
# return statement. | ||
# | ||
# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/ | ||
# and http://varnish-cache.org/trac/wiki/VCLExamples for more examples. | ||
|
||
# Marker to tell the VCL compiler that this VCL has been adapted to the | ||
# new 4.0 format. | ||
vcl 4.0; | ||
|
||
# https://github.com/Dridi/libvmod-querystring | ||
import querystring; | ||
|
||
# Default backend definition. Set this to point to your content server. | ||
backend nytco { | ||
# todo define back-end host | ||
.host = "nginx"; | ||
.port = "8080"; | ||
} | ||
|
||
# Define an access control list to restrict cache purging. | ||
acl purge { | ||
"192.168.33.1"/8; | ||
} | ||
|
||
sub vcl_recv { | ||
# todo define host name | ||
#if (req.http.host == "{{environment-specific-hostname}}") { | ||
# set req.backend_hint = nytco; | ||
#} | ||
# Fall-through for admin interface requests | ||
if (req.url~ "^/wp-admin/") { | ||
return (pass); | ||
} | ||
|
||
# Purge the cache if the client is allowed to. | ||
if (req.method == "PURGE") { | ||
if (!client.ip ~ purge) { | ||
return(synth(405,"Not allowed.")); | ||
} | ||
return (purge); | ||
} | ||
|
||
set req.http.host = "dev.nytco.com"; | ||
# Remove querystrings. | ||
set req.url = querystring.remove(req.url); | ||
|
||
# Ignore all cookies. | ||
unset req.http.cookie; | ||
} | ||
|
||
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. | ||
} | ||
|
||
sub vcl_deliver { | ||
# Fall-through for dev that doesn't work right now. Prob need to do something with beresp too. | ||
set resp.http.age = "0"; | ||
|
||
# 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. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# Parse the environment variables and auto-create the default.vcl file | ||
# /parse | ||
|
||
# Start varnish and log | ||
varnishd -F -f /etc/varnish/default.vcl -s malloc,100M -a 0.0.0.0:${VARNISH_PORT} | ||
# varnishlog |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.