Repository navigation
Expand file tree
/
Copy pathDockerfile.build
More file actions
60 lines (47 loc) · 2.24 KB
/
Copy pathDockerfile.build
File metadata and controls
60 lines (47 loc) · 2.24 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
FROM debian:bookworm-slim AS cache
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
FROM golang:alpine AS backend
WORKDIR /app
RUN go install github.com/a-h/templ/cmd/templ@latest
COPY ./go.mod ./go.sum ./
RUN go mod download
COPY . .
ARG TARGETOS
ARG TARGETARCH
RUN templ generate
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-s -w" -o app .
FROM alpine:3.24 AS busybox
# The shell's tools for looking around the container (issue 413), on
# purpose without network tools (wget, nc, ...).
ARG SHELL_APPLETS="sh ls cat less head tail grep find vi env ps df du pwd echo test readlink id touch mkdir cp mv rm chmod"
RUN apk add --no-cache busybox-static \
&& mkdir -p /rootfs/bin \
&& cp /bin/busybox.static /rootfs/bin/busybox \
&& for applet in $SHELL_APPLETS; do ln -s /bin/busybox /rootfs/bin/$applet; done \
&& ln -s /etherpad-go /rootfs/app \
&& mkdir -p /writable/var /writable/data /writable/tmp \
&& chmod 1777 /writable/tmp
FROM scratch AS runtime
EXPOSE 3000
ENV NODE_ENV=production
# The server runs as an unprivileged user. It writes to /var (the SQLite
# database var/etherpad.db and the update state) and to /data (settings.json
# saved in the admin UI); both belong to that user in the image. A volume
# or host directory mounted there must be writable for 65532: one from an
# image before this one belongs to root; hand it over once with
# docker run --rm -v <volume>:/var alpine chown -R 65532:65532 /var
# /tmp is there for temporary files (the PDF export embeds the pad, the PDF
# import restores it, through a temporary directory).
# The root (assets, /APIKEY.txt, relative favicon paths) stays /.
ENV ETHERPAD_SETTINGS_PATH=/
ENV ETHERPAD_SETTINGS_FILE=/data/settings.json
# Named like in the README, and on PATH: `docker exec <container>
# etherpad-go config show`, or a shell (busybox) with `docker exec -it
# <container> sh` (busybox: sh, ls, cat, vi, ...). /app stays as a link for deployments that start /app.
COPY --from=backend /app/app /etherpad-go
COPY --from=busybox /rootfs /
COPY --from=busybox --chown=65532:65532 /writable/ /
COPY --from=cache /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
ENV PATH="/:/bin"
USER 65532:65532
ENTRYPOINT ["/etherpad-go"]