Comments (3)
I took a look at https://github.com/swarmstack/caddy/blob/master/Dockerfile (which is a fork of your repo) and I had to update the www
dir. Then it worked.
Then I decided to add upx
.
Then I decided to put the final layer into alpine to have curl
in the final image. Needed to do my health check.
If you like it, I can do a PR.
Cheers!
ARG caddy_version="v1.0.0"
ARG plugins="cache,expires,git,jwt,prometheus,realip,reauth,minify,cors"
ARG DEBIAN_FRONTEND=noninteractive
ARG CREATED_DATE="not-set"
ARG SOURCE_COMMIT="not-set"
# LAYER base — — — — — — — — — — — — — — — — — — — — — — — — — — —
FROM alpine:3.9 AS caddy-base
RUN set -eux && \
apk --update --no-cache add curl="7.64.0-r2" tini="0.18.0-r0" && \
rm -rf /var/cache/apk/*
ARG CREATED_DATE
ARG SOURCE_COMMIT
ENV CREATED_DATE=${CREATED_DATE}
ENV SOURCE_COMMIT=${SOURCE_COMMIT}
# best practice from https://github.com/opencontainers/image-spec/blob/master/annotations.md
LABEL org.opencontainers.image.authors="Pascal Andy https://firepress.org/en/contact/" \
org.opencontainers.image.vendors="https://firepress.org/" \
org.opencontainers.image.created="${CREATED_DATE}" \
org.opencontainers.image.revision="${SOURCE_COMMIT}" \
org.opencontainers.image.title="Caddy V1" \
org.opencontainers.image.description="Docker image for Caddy" \
org.opencontainers.image.url="https://hub.docker.com/r/devmtl/caddyfire/tags/" \
org.opencontainers.image.source="https://github.com/not shared at the moment" \
org.opencontainers.image.licenses="GNUv3 https://github.com/pascalandy/GNU-GENERAL-PUBLIC-LICENSE/blob/master/LICENSE.md" \
org.firepress.image.goversion="1.12" \
org.firepress.image.schemaversion="1.0"
# copy caddy binary and ca certs
COPY Caddyfile /etc/Caddyfile
# set default path for certs
VOLUME ["/etc/caddycerts"]
ENV CADDYPATH=/etc/caddycerts
# serve from /srv
VOLUME /srv
WORKDIR /srv
COPY index.html /srv/index.html
# LAYER build — — — — — — — — — — — — — — — — — — — — — — — — — — —
# Build stage by @abiosoft https://github.com/abiosoft/caddy-docker
FROM golang:1.12-alpine AS build
ARG caddy_version
ARG plugins
ARG DEBIAN_FRONTEND
RUN set -eux && \
apk --update --no-cache add git ca-certificates upx
# caddy
RUN git clone https://github.com/mholt/caddy -b "${caddy_version}" /go/src/github.com/mholt/caddy \
&& cd /go/src/github.com/mholt/caddy \
&& git checkout -b "${caddy_version}"
# 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/mholt/caddy/caddyhttp/$plugin.go ; \
done
# builder dependency
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 disabled
RUN cd /go/src/github.com/mholt/caddy/caddy \
&& 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 \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /go/bin/caddy
# compress (reduce size by about 46%)
RUN upx /go/bin/caddy && upx -t /go/bin/caddy
# test
RUN /go/bin/caddy -version && /go/bin/caddy -plugins
# LAYER final — — — — — — — — — — — — — — — — — — — — — — — — — — —
FROM caddy-base AS caddy-final
COPY --from=build /go/bin/caddy /bin/caddy
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
ENTRYPOINT [ "/sbin/tini", "--" ]
CMD ["/bin/caddy", "-conf", "/etc/Caddyfile", "-log", "stdout", "-agree"]
# WIP, add scanner, see how we do it with Ghost
from caddy.
I switched the build process to rely on go.mod
's resolution of packages and package versions, removing a lot of unnecessary scripting during the build process. I also added a short script to generate the main package from a comma-seperated list of packages, copying the functions of and removing the dependence on abisoft's caddyplug package.
from caddy.
@pascalandy Thanks for your suggestions, they helped!
from caddy.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caddy.