-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (34 loc) · 1.09 KB
/
Dockerfile
File metadata and controls
45 lines (34 loc) · 1.09 KB
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
ARG GO_VERSION=1.25
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS build
WORKDIR /work
# Install git so that go build populates the VCS details in build info, which
# is then reported to Tailscale in the node version string.
RUN apk --no-cache add git=2.52.0-r0
COPY go.mod go.sum ./
RUN go mod download
COPY . .
ARG TARGETOS TARGETARCH TARGETVARIANT
RUN \
if [ "${TARGETARCH}" = "arm" ] && [ -n "${TARGETVARIANT}" ]; then \
export GOARM="${TARGETVARIANT#v}"; \
fi; \
GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -v ./cmd/caddy
# From https://github.com/caddyserver/caddy-docker/blob/master/2.10/alpine/Dockerfile
FROM alpine:3.21
RUN mkdir -p \
/config/caddy \
/data/caddy \
/etc/caddy \
/usr/share/caddy
COPY --from=build /work/caddy /usr/bin/caddy
COPY examples/simple.caddyfile /etc/caddy/Caddyfile
# See https://caddyserver.com/docs/conventions#file-locations for details
ENV XDG_CONFIG_HOME=/config
ENV XDG_DATA_HOME=/data
EXPOSE 80
EXPOSE 443
EXPOSE 443/udp
EXPOSE 2019
WORKDIR /srv
CMD ["run", "--config", "/etc/caddy/Caddyfile"]
ENTRYPOINT ["caddy"]