Docker image using disk-backed Varnish instance for caching.
On startup it uses the AWS CLI to copy vcl file from location specified by S3_VCL_FILE
environment variable.
Optionally, a local file can also be configured for development purposes
The following environment settings are expected:
S3_VCL_FILE
- The location of a vcl file to use. Expected S3Uri as it is used by aws s3 cp command.VARNISH_CACHE_FOLDER
- Folder where disk backed cache is stored.VARNISH_CACHE_SIZE
- Size of cache.AWS_PROFILE
- Required to run locally
The following configuration is optional:
VARNISH_CACHE_FILE
- The name of varnish storage file (e.g.varnish_cache.bin
). If specified it is appended toVARNISH_CACHE_FOLDER
to create file (if unspecified folder only is used)INCOMING_QUEUE
- the name of the queue that the cleanup handler listens toVARNISH_ADDRESS
- The location of varnish used by the cleanup handler. Defaults to localhostAWS_REGION
- The AWS region. Defaults to eu-west-1USE_LOCAL_CONFIG
- Whether to use a local config file over S3.
NOTE: using USE_LOCAL_CONFIG
requires a mount
to be added to the docker run
containing the VCL
# build
docker build -t dlcs-varnish:local .
# run
docker run -it --rm \
--env S3_VCL_FILE='s3://my-bucket/varnish-config.vcl' \
--env VARNISH_CACHE_FOLDER='/path/to/folder' \
--env VARNISH_CACHE_SIZE='100M' \
--env-file='/path/to/env' \
{REQUIRED FOR LOCAL RUNNING}--volume $HOME\.aws\credentials:/root/.aws/credentials:ro \
{OPTIONAL}--volume ./etc/:/mnt/varnish/ \
dlcs-varnish:local
Additionally, there is a standalone docker container for the cleanup handler.
Required:
AWS_PROFILE
- Required to run locally
Optional:
VARNISH_ADDRESS
- The location of varnish used by the cleanup handler. Defaults to localhostAWS_REGION
- The region used by the cleanup handler. Defaults to eu-west-1
# build
docker build -t dlcs-varnish-cleanup:local ./varnish-cleanup
# run
docker run -it --rm \
--env-file='/path/to/env'
{REQUIRED FOR LOCAL RUNNING}--volume=$HOME\.aws\credentials:/root/.aws/credentials:ro
dlcs-varnish:local