Skip to content

Instantly share code, notes, and snippets.

@xjoker
Created April 18, 2023 03:17
Show Gist options
  • Save xjoker/535203f323f3bbc27f2d8788875e5d7d to your computer and use it in GitHub Desktop.
Save xjoker/535203f323f3bbc27f2d8788875e5d7d to your computer and use it in GitHub Desktop.
build caddy webdav
FROM golang:1.20.3 AS build
ARG version
ARG xcaddy_arg
WORKDIR /src
RUN go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
RUN xcaddy build ${version} ${xcaddy_arg}
FROM alpine:3.16 AS base
ARG version
WORKDIR /src
COPY --from=build /src/ .
ENV CADDY_VERSION ${version}
RUN mkdir -p \
/config/caddy \
/data/caddy \
/etc/caddy \
/usr/share/caddy; \
wget -O /etc/caddy/Caddyfile "https://raw.githubusercontent.com/caddyserver/dist/${version}/config/Caddyfile"; \
wget -O /usr/share/caddy/index.html "https://raw.githubusercontent.com/caddyserver/dist/${version}/welcome/index.html"; \
cp /src/caddy /usr/bin/caddy; \
chmod +x /usr/bin/caddy; \
caddy version
ENV XDG_CONFIG_HOME /config
ENV XDG_DATA_HOME /data
LABEL org.opencontainers.image.version=${version}
LABEL org.opencontainers.image.title=Caddy
EXPOSE 80
EXPOSE 443
EXPOSE 443/udp
EXPOSE 2019
WORKDIR /srv
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile", "--adapter", "caddyfile"]
@xjoker
Copy link
Author

xjoker commented Apr 18, 2023

docker build --build-arg version="v2.6.4" --build-arg xcaddy_arg="--with github.com/mholt/caddy-webdav" -t xjoker/caddy-webdav:v2.6.4 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment