From 2edd3f7c6c1534f2af626208774dcd8d3682f0cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?yJan=20Christian=20Gr=C3=BCnhage?= Date: Wed, 17 May 2017 18:33:21 +0200 Subject: [PATCH] Add plugin support and update to caddy v0.10.2 --- Dockerfile | 25 ++++++++++++++++--------- plugins.txt | 1 + root/usr/local/bin/run.sh | 3 +++ 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 plugins.txt create mode 100755 root/usr/local/bin/run.sh diff --git a/Dockerfile b/Dockerfile index ca53d66..bbe5ed0 100755 --- a/Dockerfile +++ b/Dockerfile @@ -4,31 +4,38 @@ MAINTAINER Jan Christian Grünhage ENV GOPATH /gopath ENV CADDY_REPO_OWNER mholt ENV CADDY_REPO_NAME caddy -ENV CADDY_BRANCH tags/v0.9.5 +ENV CADDY_BRANCH tags/v0.10.2 ENV CADDYPATH /caddy ENV UID 192 ENV GID 192 -RUN addgroup -g $GID -S caddy \ - && adduser -u $UID -g $GID -S caddy +COPY plugins.txt /plugins RUN apk add --update musl \ - && apk add --no-cache build-base libcap tini go git \ + && apk add --no-cache build-base su-exec libcap tini go git \ && mkdir -p $GOPATH/src/github.com/$CADDY_REPO_OWNER \ && cd $GOPATH/src/github.com/$CADDY_REPO_OWNER \ && git clone https://github.com/$CADDY_REPO_OWNER/$CADDY_REPO_NAME \ && cd $CADDY_REPO_NAME \ && git checkout $CADDY_BRANCH \ + && cd caddy/caddymain \ + && export line="$(grep -n "// This is where other plugins get plugged in (imported)" < run.go | sed 's/^\([0-9]\+\):.*$/\1/')" \ + && head -n ${line} run.go > newrun.go \ + && cat /plugins >> newrun.go \ + && line=`expr $line + 1` \ + && tail -n +${line} run.go >> newrun.go \ + && rm -f run.go \ + && mv newrun.go run.go \ && go get github.com/$CADDY_REPO_OWNER/$CADDY_REPO_NAME/... \ && mv $GOPATH/bin/caddy /usr/bin \ && setcap cap_net_bind_service=+ep /usr/bin/caddy \ && apk del --purge build-base go \ && mkdir $CADDYPATH \ - && rm -rf $GOPATH /var/cache/apk/* + && rm -rf $GOPATH /var/cache/apk/* /plugins + +COPY root / -USER caddy EXPOSE 2015 80 443 -VOLUME [ "$CADDYPATH" ] +VOLUME ["$CADDYPATH" ] WORKDIR "$CADDYPATH" -ENTRYPOINT [ "/sbin/tini" ] -CMD [ "caddy", "-quic", "--conf", "/caddy/Caddyfile" ] +ENTRYPOINT ["/sbin/tini", "--", "/usr/local/bin/run.sh"] diff --git a/plugins.txt b/plugins.txt new file mode 100644 index 0000000..5033c81 --- /dev/null +++ b/plugins.txt @@ -0,0 +1 @@ + _ "github.com/abiosoft/caddy-git" diff --git a/root/usr/local/bin/run.sh b/root/usr/local/bin/run.sh new file mode 100755 index 0000000..8128727 --- /dev/null +++ b/root/usr/local/bin/run.sh @@ -0,0 +1,3 @@ +#!/bin/sh +chown -R ${UID}:${GID} /caddy +exec su-exec ${UID}:${GID} /usr/bin/caddy -quic --conf /caddy/Caddyfile