-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
40 lines (30 loc) · 1.01 KB
/
Dockerfile
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
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
# xcaddy is used to build caddy, we use this to allow access to build custom add-ons
# see:
# - https://github.com/caddyserver/xcaddy
# - https://hub.docker.com/_/caddy/tags?page=1&name=builder-alpine
FROM --platform=${BUILDPLATFORM:-linux/amd64} docker.io/caddy:builder-alpine AS builder
# Keep this version current!!
# see:
# - https://github.com/caddyserver/caddy/releases
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
xcaddy build v2.7.0-beta.2
### final image
FROM --platform=${BUILDPLATFORM:-linux/amd64} docker.io/alpine
RUN apk add --no-cache \
ca-certificates
# add new user, lets not run as root
RUN adduser -D app
COPY --from=builder /usr/bin/caddy /caddy
# Default config + content
WORKDIR /app/content
COPY Caddyfile /app/Caddyfile
RUN chown -R app /app
# tell caddy where to listen
ENV SITE_ADDRESS=0.0.0.0:8080
# change user to "app"
USER app
CMD ["/caddy", "run", "--config", "/app/Caddyfile", "--adapter", "caddyfile"]