Skip to content

Commit 542497f

Browse files
authored
Merge pull request #8 from dlcs/feature/cache_folder
Varnish cache_file name is optional
2 parents 6c2f649 + 663807f commit 542497f

File tree

6 files changed

+23
-14
lines changed

6 files changed

+23
-14
lines changed

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:20.04
1+
FROM ubuntu:22.04
22

33
LABEL maintainer="Donald Gray <donald.gray@digirati.com>"
44
LABEL org.opencontainers.image.source=https://github.com/dlcs/dlcs-varnish
@@ -7,13 +7,13 @@ LABEL org.opencontainers.image.description="Varnish on Ubuntu, vcl sourced from
77
RUN apt-get update -y && apt-get install -y varnish python3-pip
88
RUN pip install awscli
99

10-
COPY start.sh /start.sh
11-
RUN chmod +x /start.sh
12-
1310
WORKDIR /usr/app/src
1411
COPY varnish-cleanup/requirements.txt ./
1512
RUN pip install -r requirements.txt
1613

14+
COPY start.sh /start.sh
15+
RUN chmod +x /start.sh
16+
1717
COPY varnish-cleanup/cleanup_handler.py ./
1818
COPY varnish-cleanup/app ./app
1919

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ The following environment settings are expected:
1212
* `VARNISH_CACHE_FOLDER` - Folder where disk backed cache is stored.
1313
* `VARNISH_CACHE_SIZE` - Size of cache.
1414
* `AWS_PROFILE` - Required to run locally
15-
* `INCOMING_QUEUE` - the name of the queue that the cleanup handler listens to
1615

1716
The following configuration is optional:
1817

18+
* `VARNISH_CACHE_FILE` - The name of varnish [storage file](https://varnish-cache.org/docs/trunk/users-guide/storage-backends.html#file) (e.g. `varnish_cache.bin`). If specified it is appended to `VARNISH_CACHE_FOLDER` to create file (if unspecified folder only is used)
19+
* `INCOMING_QUEUE` - the name of the queue that the cleanup handler listens to
1920
* `VARNISH_ADDRESS` - The location of varnish used by the cleanup handler. Defaults to localhost
2021
* `AWS_REGION` - The AWS region. Defaults to eu-west-1
2122
* `USE_LOCAL_CONFIG` - Whether to use a local config file over S3.
@@ -34,14 +35,14 @@ docker run -it --rm \
3435
--env VARNISH_CACHE_SIZE='100M' \
3536
--env-file='/path/to/env' \
3637
{REQUIRED FOR LOCAL RUNNING}--volume $HOME\.aws\credentials:/root/.aws/credentials:ro \
37-
{OPTIONAL}--mount type=bind,source=.\etc\default.vcl,target=/mnt/varnish/default.vcl \
38+
{OPTIONAL}--volume ./etc/:/mnt/varnish/ \
3839
dlcs-varnish:local
3940
```
40-
# varnish-cleanup
41+
## varnish-cleanup
4142

4243
Additionally, there is a standalone docker container for the cleanup handler.
4344

44-
## Configuration
45+
### Configuration
4546

4647
Required:
4748
* `AWS_PROFILE` - Required to run locally

start.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ RELOAD_VCL=1
1515

1616
mkdir -p ${VARNISH_CACHE_FOLDER}
1717

18-
varnishd -a 0.0.0.0:${VARNISH_PORT} -T 127.0.0.1:6082 -f /etc/varnish/default.vcl -s file,${VARNISH_CACHE_FOLDER}/varnish_cache.bin,${VARNISH_CACHE_SIZE}
18+
varnishd -a 0.0.0.0:${VARNISH_PORT} -T 127.0.0.1:6082 -f /etc/varnish/default.vcl -s file,${VARNISH_CACHE_FOLDER}/${VARNISH_CACHE_FILE},${VARNISH_CACHE_SIZE}
1919

20-
varnishlog &
2120

22-
# Start varnish cleanup
23-
24-
python3 /usr/app/src/cleanup_handler.py
21+
if [ -z "$INCOMING_QUEUE" ]
22+
then
23+
echo 'no queue monitoring'
24+
varnishlog
25+
else
26+
# Start varnish cleanup
27+
varnishlog &
28+
python3 /usr/app/src/cleanup_handler.py
29+
fi

varnish-cleanup/app/aws_factory.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import boto3
2-
from moto import sqs
32

43
from app.settings import LOCALSTACK, REGION, LOCALSTACK_ADDRESS
54
from logzero import logger

varnish-cleanup/requirements.txt

-634 Bytes
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mock==5.1.0
2+
moto==4.1.14
3+
pytest==7.4.0
4+
requests-mock==1.11.0

0 commit comments

Comments
 (0)