Skip to content

Commit

Permalink
add caddy to docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mnot committed Jul 11, 2023
1 parent 0f8ed5d commit 7edcd68
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 4 deletions.
10 changes: 9 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ LABEL maintainer="Mark Nottingham <[email protected]>"

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
nodejs npm git openssh-client \
nodejs npm git openssh-client telnet \
squid \
nginx \
trafficserver \
apache2 \
varnish \
golang \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean

Expand Down Expand Up @@ -61,6 +62,13 @@ EXPOSE 8004
EXPOSE 8005


# caddy

RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
RUN ~/go/bin/xcaddy build --with github.com/caddyserver/cache-handler
COPY caddy/Caddyfile /etc/caddy/Caddyfile
EXPOSE 8006

# setup

COPY setup.sh /sbin/setup.sh
Expand Down
1 change: 0 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ To add a new reverse proxy:
4. In `serve.sh`, start the server in the background
5. In `/test-docker.sh`, add the `PROXY_PORT` to the case statement

To run on the CI server, modify `/.circleci/config.yml` suitably.
28 changes: 28 additions & 0 deletions docker/caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.

{
order cache before rewrite
cache
}

:8006 {
cache {
default_cache_control no-store
}
reverse_proxy http://127.0.0.1:8000 {
transport http {
dial_timeout 10s
}
}
}

# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile
3 changes: 3 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ if [[ ! -z $1 ]] ; then
# varnish
sed -i s/127.0.0.1/$1/ /etc/varnish/default.vcl

# caddy
sed -i s/127.0.0.1/$1/ /etc/caddy/Caddyfile

serve.sh
fi

Expand Down
3 changes: 3 additions & 0 deletions docker/serve.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ source /etc/apache2/envvars

echo "* Starting Varnish"
/usr/sbin/varnishd -j unix -a 0.0.0.0:8005 -f /etc/varnish/default.vcl -p default_ttl=0 -p default_grace=0 -p default_keep=3600 -s malloc,64M

echo "* Starting Caddy"
HOME=/root /caddy run --config /etc/caddy/Caddyfile
7 changes: 5 additions & 2 deletions test-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
PIDFILE=/tmp/http-cache-test-server.pid


ALL_PROXIES=(squid nginx apache trafficserver varnish nuster)
ALL_PROXIES=(squid nginx apache trafficserver varnish caddy nuster)
DOCKER_PORTS=""
for PORT in {8001..8005}; do
for PORT in {8001..8006}; do
DOCKER_PORTS+="-p ${PORT}:${PORT} "
done

Expand Down Expand Up @@ -71,6 +71,9 @@ function test_proxy {
varnish)
PROXY_PORT=8005
;;
caddy)
PROXY_PORT=8006
;;
nuster)
PROXY_PORT=9001
;;
Expand Down

0 comments on commit 7edcd68

Please sign in to comment.