Skip to content

Commit

Permalink
Merge pull request #2 from dlcs/feature/set_http_port
Browse files Browse the repository at this point in the history
Set HTTP Port with Envvar
  • Loading branch information
donaldgray committed May 3, 2023
2 parents d159e8a + bec6d26 commit 29f9fb2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- master
tags:
- "*"
pull_request:
branches:
- master
Expand All @@ -19,23 +21,35 @@ jobs:

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/dlcs/dlcs-varnish
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,enable=true,prefix=,format=long
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/dlcs/dlcs-varnish:${{ github.sha }}
push: true
labels: ${{ steps.docker_meta.outputs.labels }}
tags: ${{ steps.docker_meta.outputs.tags }}


4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM ubuntu:20.04

LABEL maintainer="Donald Gray <donald.gray@digirati.com>"
LABEL org.opencontainers.image.source=https://github.com/dlcs/dlcs-varnish
LABEL org.opencontainers.image.description="Varnish on Ubuntu, vcl sourced from S3"

RUN apt-get update -y && apt-get install -y varnish python3-pip
RUN pip install awscli

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The following environment files are expected:
* `S3_VCL_FILE` - The location of a vcl file to use. Expected S3Uri as it is used by [aws s3 cp](https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html) command.
* `VARNISH_CACHE_FOLDER` - Folder where disk backed cache is stored.
* `VARNISH_CACHE_SIZE` - Size of cache.
* `VARNISH_PORT` - Which port Varnish should listen on (defaults to 80)

## Running

Expand All @@ -19,7 +20,7 @@ The following environment files are expected:
docker build -t dlcs-varnish:local .

# run
sudo docker run -t -i --rm \
docker run -it --rm \
--env AWS_ACCESS_KEY_ID='xxx' \
--env AWS_SECRET_ACCESS_KEY='xxx' \
--env S3_VCL_FILE='s3://my-bucket/varnish-config.vcl' \
Expand Down
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ RELOAD_VCL=1

mkdir -p ${VARNISH_CACHE_FOLDER}

varnishd -a 0.0.0.0:80 -T 127.0.0.1:6082 -f /etc/varnish/default.vcl -s file,${VARNISH_CACHE_FOLDER}/varnish_cache.bin,${VARNISH_CACHE_SIZE}
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}

varnishlog

0 comments on commit 29f9fb2

Please sign in to comment.