Skip to content

Commit 7edcd68

Browse files
committed
add caddy to docker
1 parent 0f8ed5d commit 7edcd68

File tree

6 files changed

+48
-4
lines changed

6 files changed

+48
-4
lines changed

docker/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ LABEL maintainer="Mark Nottingham <[email protected]>"
66

77
RUN apt-get update \
88
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
9-
nodejs npm git openssh-client \
9+
nodejs npm git openssh-client telnet \
1010
squid \
1111
nginx \
1212
trafficserver \
1313
apache2 \
1414
varnish \
15+
golang \
1516
&& rm -rf /var/lib/apt/lists/* \
1617
&& apt-get clean
1718

@@ -61,6 +62,13 @@ EXPOSE 8004
6162
EXPOSE 8005
6263

6364

65+
# caddy
66+
67+
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
68+
RUN ~/go/bin/xcaddy build --with github.com/caddyserver/cache-handler
69+
COPY caddy/Caddyfile /etc/caddy/Caddyfile
70+
EXPOSE 8006
71+
6472
# setup
6573

6674
COPY setup.sh /sbin/setup.sh

docker/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ To add a new reverse proxy:
1414
4. In `serve.sh`, start the server in the background
1515
5. In `/test-docker.sh`, add the `PROXY_PORT` to the case statement
1616

17-
To run on the CI server, modify `/.circleci/config.yml` suitably.

docker/caddy/Caddyfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# The Caddyfile is an easy way to configure your Caddy web server.
2+
#
3+
# Unless the file starts with a global options block, the first
4+
# uncommented line is always the address of your site.
5+
#
6+
# To use your own domain name (with automatic HTTPS), first make
7+
# sure your domain's A/AAAA DNS records are properly pointed to
8+
# this machine's public IP, then replace ":80" below with your
9+
# domain name.
10+
11+
{
12+
order cache before rewrite
13+
cache
14+
}
15+
16+
:8006 {
17+
cache {
18+
default_cache_control no-store
19+
}
20+
reverse_proxy http://127.0.0.1:8000 {
21+
transport http {
22+
dial_timeout 10s
23+
}
24+
}
25+
}
26+
27+
# Refer to the Caddy docs for more information:
28+
# https://caddyserver.com/docs/caddyfile

docker/entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ if [[ ! -z $1 ]] ; then
2020
# varnish
2121
sed -i s/127.0.0.1/$1/ /etc/varnish/default.vcl
2222

23+
# caddy
24+
sed -i s/127.0.0.1/$1/ /etc/caddy/Caddyfile
25+
2326
serve.sh
2427
fi
2528

docker/serve.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ source /etc/apache2/envvars
1515

1616
echo "* Starting Varnish"
1717
/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
18+
19+
echo "* Starting Caddy"
20+
HOME=/root /caddy run --config /etc/caddy/Caddyfile

test-docker.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
PIDFILE=/tmp/http-cache-test-server.pid
66

77

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

@@ -71,6 +71,9 @@ function test_proxy {
7171
varnish)
7272
PROXY_PORT=8005
7373
;;
74+
caddy)
75+
PROXY_PORT=8006
76+
;;
7477
nuster)
7578
PROXY_PORT=9001
7679
;;

0 commit comments

Comments
 (0)