Skip to content

Commit

Permalink
Update build to support Caddy 1.0.0. Now produces alpine:3.9.3 image …
Browse files Browse the repository at this point in the history
…instead of scratch
  • Loading branch information
Mike Holloway committed May 1, 2019
1 parent 537cdcd commit f349a1d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 34 deletions.
38 changes: 24 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ FROM golang:1.12-alpine as build

ARG BUILD_DATE
ARG VCS_REF
ARG DEBIAN_FRONTED=noninteractive
ARG DEBIAN_FRONTEND=noninteractive

ARG caddy_version="v0.11.5"
ARG caddy_version="v1.0.0"
ARG plugins="cache,expires,git,jwt,prometheus,realip,reauth"

RUN apk add --no-cache --no-progress git
Expand All @@ -28,17 +28,32 @@ RUN for plugin in $(echo $plugins | tr "," " "); do \
done

# builder dependency
RUN git clone https://github.com/caddyserver/builds /go/src/github.com/caddyserver/builds
RUN git clone https://github.com/dustin/go-humanize /go/src/github.com/dustin/go-humanize
RUN git clone https://github.com/gorilla/websocket /go/src/github.com/gorilla/websocket
RUN git clone https://github.com/jimstudt/http-authentication /go/src/github.com/jimstudt/http-authentication
RUN git clone https://github.com/naoina/toml /go/src/github.com/naoina/toml
RUN git clone https://github.com/naoina/go-stringutil /go/src/github.com/naoina/go-stringutil
RUN git clone https://github.com/VividCortex/ewma /go/src/github.com/VividCortex/ewma
RUN git clone https://github.com/cheekybits/genny /go/src/github.com/cheekybits/genny
RUN git clone https://github.com/marten-seemann/qpack /go/src/github.com/marten-seemann/qpack
RUN git clone https://github.com/marten-seemann/qtls /go/src/github.com/marten-seemann/qtls

# build with telemetry enabled
RUN cd /go/src/github.com/mholt/caddy/caddy \
&& git checkout -f \
&& go run build.go \
&& mv caddy /go/bin
&& sed -i 's/h2quic/http3/g' /go/src/github.com/mholt/caddy/caddyhttp/proxy/upstream_test.go \
&& sed -i 's/h2quic/http3/g' /go/src/github.com/mholt/caddy/caddyhttp/proxy/reverseproxy_test.go \
&& sed -i 's/h2quic/http3/g' /go/src/github.com/mholt/caddy/caddyhttp/proxy/proxy_test.go \
&& sed -i 's/h2quic/http3/g' /go/src/github.com/mholt/caddy/caddyhttp/proxy/reverseproxy.go \
&& sed -i 's/h2quic/http3/g' /go/src/github.com/mholt/caddy/caddyhttp/httpserver/server.go \
&& go install
#&& mv caddy /go/bin

# test
RUN /go/bin/caddy -version
RUN /go/bin/caddy -plugins

#
# Compress Caddy with upx
# Compress Caddy with UPX
#
FROM debian:stable as compress

Expand All @@ -59,14 +74,10 @@ RUN curl --silent --show-error --fail --location -o - \
COPY --from=build /go/bin/caddy /usr/bin/caddy
RUN /usr/bin/upx --ultra-brute /usr/bin/caddy

# test
RUN /usr/bin/caddy -version
RUN /usr/bin/caddy -plugins

#
# Final image
#
FROM scratch
FROM alpine:3.9.3

LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-url="https://github.com/swarmstack/caddy.git" \
Expand All @@ -78,7 +89,6 @@ MAINTAINER Mike Holloway <[email protected]>
# copy caddy binary and ca certs
COPY --from=compress /usr/bin/caddy /bin/caddy
COPY --from=compress /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=compress /usr/bin/curl /bin/curl

# copy default caddyfile
COPY Caddyfile /etc/Caddyfile
Expand All @@ -92,4 +102,4 @@ VOLUME ["/www"]
WORKDIR /www
COPY index.html /www/index.html

CMD ["/bin/caddy", "--conf", "/etc/Caddyfile", "--log", "stdout", "-agree", "--root", "/www"]
CMD ["/bin/caddy", "-conf", "/etc/Caddyfile", "-log", "stdout", "-agree", "-root", "/www"]
46 changes: 26 additions & 20 deletions Dockerfile-no-stats
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ FROM golang:1.12-alpine as build

ARG BUILD_DATE
ARG VCS_REF
ARG DEBIAN_FRONTEND=noninteractive

ARG caddy_version="v0.11.5"
ARG caddy_version="v1.0.0"
ARG plugins="cache,expires,git,jwt,prometheus,realip,reauth"
ARG DEBIAN_FRONTED=noninteractive

RUN apk add --no-cache --no-progress git

Expand All @@ -28,20 +28,31 @@ RUN for plugin in $(echo $plugins | tr "," " "); do \
done

# builder dependency
RUN git clone https://github.com/caddyserver/builds /go/src/github.com/caddyserver/builds

# Caddy v0.11.1: var EnableTelemetry = true
# build with telemetry disabled
RUN git clone https://github.com/dustin/go-humanize /go/src/github.com/dustin/go-humanize
RUN git clone https://github.com/gorilla/websocket /go/src/github.com/gorilla/websocket
RUN git clone https://github.com/jimstudt/http-authentication /go/src/github.com/jimstudt/http-authentication
RUN git clone https://github.com/naoina/toml /go/src/github.com/naoina/toml
RUN git clone https://github.com/naoina/go-stringutil /go/src/github.com/naoina/go-stringutil
RUN git clone https://github.com/VividCortex/ewma /go/src/github.com/VividCortex/ewma
RUN git clone https://github.com/cheekybits/genny /go/src/github.com/cheekybits/genny
RUN git clone https://github.com/marten-seemann/qpack /go/src/github.com/marten-seemann/qpack
RUN git clone https://github.com/marten-seemann/qtls /go/src/github.com/marten-seemann/qtls

# build without telemetry enabled
RUN cd /go/src/github.com/mholt/caddy/caddy \
&& git checkout -f \
&& grep -i 'enabletelemetry = ' /go/src/github.com/mholt/caddy/caddy/caddymain/run.go
&& sed -i 's/h2quic/http3/g' /go/src/github.com/mholt/caddy/caddyhttp/proxy/upstream_test.go \
&& sed -i 's/h2quic/http3/g' /go/src/github.com/mholt/caddy/caddyhttp/proxy/reverseproxy_test.go \
&& sed -i 's/h2quic/http3/g' /go/src/github.com/mholt/caddy/caddyhttp/proxy/proxy_test.go \
&& sed -i 's/h2quic/http3/g' /go/src/github.com/mholt/caddy/caddyhttp/proxy/reverseproxy.go \
&& sed -i 's/h2quic/http3/g' /go/src/github.com/mholt/caddy/caddyhttp/httpserver/server.go \
&& sed -i 's/Telemetry = true/Telemetry = false/' /go/src/github.com/mholt/caddy/caddy/caddymain/run.go \
&& go install

RUN sed -i'.bak' "s/Telemetry = true/Telemetry = false/" /go/src/github.com/mholt/caddy/caddy/caddymain/run.go \
&& cd /go/src/github.com/mholt/caddy/caddy \
&& grep -i 'enabletelemetry = ' /go/src/github.com/mholt/caddy/caddy/caddymain/run.go \
&& go run build.go \
&& mv caddy /go/bin
# test
RUN /go/bin/caddy -version
RUN /go/bin/caddy -plugins

#
# Compress Caddy with UPX
#
FROM debian:stable as compress
Expand All @@ -63,16 +74,11 @@ RUN curl --silent --show-error --fail --location -o - \
COPY --from=build /go/bin/caddy /usr/bin/caddy
RUN /usr/bin/upx --ultra-brute /usr/bin/caddy

# test
RUN /usr/bin/caddy -version
RUN /usr/bin/caddy -plugins

#
# Final image
#
FROM alpine:latest
FROM alpine:3.9.3

# labels
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-url="https://github.com/swarmstack/caddy.git" \
org.label-schema.vcs-ref=$VCS_REF \
Expand All @@ -96,4 +102,4 @@ VOLUME ["/www"]
WORKDIR /www
COPY index.html /www/index.html

CMD ["/bin/caddy", "--conf", "/etc/Caddyfile", "--log", "stdout", "--agree", "--root", "/www"]
CMD ["/bin/caddy", "-conf", "/etc/Caddyfile", "-log", "stdout", "-agree", "-root", "/www"]

0 comments on commit f349a1d

Please sign in to comment.