From 9067c90e29063650e63455058862a92ae87de23d Mon Sep 17 00:00:00 2001 From: dave Date: Tue, 25 Oct 2016 22:51:42 -0700 Subject: [PATCH] Delete fewer things --- Dockerfile | 10 ++++++---- README.md | 8 ++------ start | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100755 start diff --git a/Dockerfile b/Dockerfile index 328a246..90fe74c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,18 @@ FROM ubuntu:trusty -RUN locale-gen en_US en_US.UTF-8 ;\ +ADD start /start + +RUN chmod +x /start ;\ + locale-gen en_US en_US.UTF-8 ;\ apt-get update ;\ apt-get install -y apt-transport-https curl ;\ curl https://repo.varnish-cache.org/ubuntu/GPG-key.txt | apt-key add - ;\ echo "deb https://repo.varnish-cache.org/ubuntu/ trusty varnish-4.0" >> /etc/apt/sources.list.d/varnish-cache.list ;\ apt-get update ;\ - DEBIAN_FRONTEND=noninteractive apt-get install -y varnish ;\ - echo '00000000-0000-0000-0000-000000000000' > /etc/varnish/secret + DEBIAN_FRONTEND=noninteractive apt-get install -y varnish WORKDIR /etc/varnish -ENTRYPOINT ["/usr/sbin/varnishd", "-f", "/etc/varnish/default.vcl", "-a", "0.0.0.0:80", "-T", "0.0.0.0:6082", "-S", "/etc/varnish/secret", "-F"] +ENTRYPOINT ["/start"] EXPOSE 80 6082 diff --git a/README.md b/README.md index 79b9d3b..1a5fe5a 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,10 @@ Container for running [Varnish Cache](https://www.varnish-cache.org/). *Advanced* -* Set memory size - append: `-s malloc,256M` -* Set a secret - mount `-v /path/to/file/containg/uuid:/etc/varnish/secret` +* Set memory size: `-e MEMSIZE=64M` +* Set a secret: `-e SECRET=00000000-0000-0000-0000-000000000000` * Expose control terminal: `-p 1234:6082` *Extras* * test.vcl - example default.vcl file - -*Notes* - -The default secret is `00000000-0000-0000-0000-000000000000`. This is INSECURE if you decide to expose the varnish control terminal. diff --git a/start b/start new file mode 100755 index 0000000..c2bbecf --- /dev/null +++ b/start @@ -0,0 +1,20 @@ +#!/bin/sh + +# Set default varnish memory cache size if not specified +if [ -z "$MEMSIZE" ]; then + export MEMSIZE=64M +fi + +# Set varnish secret if not specified +if [ ! -f /etc/varnish/secret ]; then + if [ -z "$SECRET" ]; then + SECRET=`cat /proc/sys/kernel/random/uuid` + fi + echo $SECRET > /etc/varnish/secret +fi +echo "Secret is `cat /etc/varnish/secret`" + +# Check vcl syntax +varnishd -C -f /etc/varnish/default.vcl > /dev/null || exit 1 + +exec /usr/sbin/varnishd -f /etc/varnish/default.vcl -a 0.0.0.0:80 -T 0.0.0.0:6082 -S /etc/varnish/secret -F -s malloc,${MEMSIZE} $@