forked from productionwentdown/caddy
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dockerfile-no-stats
executable file
·73 lines (55 loc) · 2.22 KB
/
Dockerfile-no-stats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#
# Build stage by @abiosoft https://github.com/abiosoft/caddy-docker
#
FROM golang:1.14-alpine as build
ARG BUILD_DATE
ARG VCS_REF
ARG DEBIAN_FRONTEND=noninteractive
ARG caddy_version="master"
ARG plugins="cache,expires,git,jwt,prometheus,realip,reauth"
RUN apk add --no-cache --no-progress git ca-certificates
# caddy
#RUN git clone https://github.com/caddyserver/caddy -b "${caddy_version}" /go/src/github.com/caddyserver/caddy \
# && cd /go/src/github.com/caddyserver/caddy \
# && git checkout -b "${caddy_version}"
# if running from master
RUN git clone https://github.com/caddyserver/caddy -b "${caddy_version}" /go/src/github.com/caddyserver/caddy
# plugin helper
RUN go get -v github.com/abiosoft/caddyplug/caddyplug
# plugins
RUN for plugin in $(echo $plugins | tr "," " "); do \
go get -v $(caddyplug package $plugin); \
printf "package caddyhttp\nimport _ \"$(caddyplug package $plugin)\"" > \
/go/src/github.com/caddyserver/caddy/caddyhttp/$plugin.go ; \
done
# Deal with https://github.com/miekg/caddy-prometheus/issues/43
COPY patches/handler.go /go/src/github.com/miekg/caddy-prometheus/handler.go
# build with telemetry disabled
RUN cd /go/src/github.com/caddyserver/caddy/caddy \
&& sed -i.bak 's/Telemetry = true/Telemetry = false/' /go/src/github.com/caddyserver/caddy/caddy/caddymain/run.go \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /go/bin/caddy
# test
RUN /go/bin/caddy -version
RUN /go/bin/caddy -plugins
#
# Final image
#
FROM scratch
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 \
org.label-schema.schema-version="1.0.0-rc1"
MAINTAINER Mike Holloway <[email protected]>
# copy caddy binary and ca certs
COPY --from=build /go/bin/caddy /bin/caddy
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
# copy default caddyfile
COPY Caddyfile /etc/Caddyfile
# set default path for certs
VOLUME ["/etc/caddycerts"]
ENV CADDYPATH=/etc/caddycerts
# serve from /www
VOLUME ["/www"]
WORKDIR /www
COPY index.html /www/index.html
CMD ["/bin/caddy", "-conf", "/etc/Caddyfile", "-log", "stdout", "-agree", "-root", "/www"]