1
0
Fork 0
caddy/Dockerfile

52 lines
1.2 KiB
Docker
Raw Permalink Normal View History

2017-10-09 20:03:30 +08:00
#
# Build stage
2017-10-09 20:03:30 +08:00
#
2019-03-24 23:08:09 +08:00
FROM golang:1.12-alpine as build
2017-10-09 20:03:30 +08:00
2018-09-17 11:59:29 +08:00
# args
ARG version="1.0.3"
# add plugin import paths here separated by commas
2017-10-09 20:03:30 +08:00
ARG plugins=""
ARG telemetry="true"
2017-10-09 20:03:30 +08:00
# build root
WORKDIR /build
2017-10-09 20:03:30 +08:00
# plugins
COPY plugger.go ./
2017-10-09 18:14:51 +08:00
# build & test
RUN apk add --no-cache git upx ca-certificates \
&& echo -e "module caddy\nrequire github.com/caddyserver/caddy v${version}" > go.mod \
&& go run plugger.go -plugins="${plugins}" -telemetry="${telemetry}" \
&& CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build \
&& upx --ultra-brute caddy \
&& ./caddy -version
2017-10-09 18:14:51 +08:00
2017-10-09 20:03:30 +08:00
#
# Final image
#
2017-10-09 18:14:51 +08:00
FROM scratch
2017-10-09 20:46:45 +08:00
# labels
2017-10-09 19:26:10 +08:00
LABEL org.label-schema.vcs-url="https://github.com/productionwentdown/caddy"
2017-10-09 20:14:04 +08:00
LABEL org.label-schema.version=${version}
2017-10-09 19:26:10 +08:00
LABEL org.label-schema.schema-version="1.0"
2018-09-17 11:59:29 +08:00
# copy binary and ca certs
COPY --from=build /build/caddy /bin/caddy
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
2017-10-09 20:46:45 +08:00
# copy default caddyfile
2017-10-09 18:48:28 +08:00
COPY Caddyfile /etc/Caddyfile
2017-10-09 18:14:51 +08:00
2017-10-09 20:46:45 +08:00
# set default caddypath
2017-10-09 18:48:28 +08:00
ENV CADDYPATH=/etc/.caddy
VOLUME /etc/.caddy
2017-10-09 18:14:51 +08:00
2017-10-09 20:46:45 +08:00
# serve from /srv
2017-10-09 18:48:28 +08:00
WORKDIR /srv
2019-08-18 16:32:23 +08:00
EXPOSE 2015
2017-10-09 18:14:51 +08:00
2018-09-01 16:32:39 +08:00
ENTRYPOINT ["/bin/caddy", "--conf", "/etc/Caddyfile", "--log", "stdout"]