Add plugin support and update to caddy v0.10.2

This commit is contained in:
Jan Christian Grünhage 2017-05-17 18:33:21 +02:00
parent 927d9344ab
commit 2edd3f7c6c
Signed by untrusted user: jcgruenhage
GPG key ID: 321A67D9EE8BC3E1
3 changed files with 20 additions and 9 deletions

View file

@ -4,31 +4,38 @@ MAINTAINER Jan Christian Grünhage <mail@janchristiangruenhage.de>
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"]

1
plugins.txt Normal file
View file

@ -0,0 +1 @@
_ "github.com/abiosoft/caddy-git"

3
root/usr/local/bin/run.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
chown -R ${UID}:${GID} /caddy
exec su-exec ${UID}:${GID} /usr/bin/caddy -quic --conf /caddy/Caddyfile