[mirror] Scalable static site server for Git forges (like GitHub Pages)
at main 53 lines 2.2 kB view raw
1# Install CA certificates. 2FROM docker.io/library/alpine:3 AS ca-certificates-builder 3RUN apk --no-cache add ca-certificates 4 5# Build supervisor. 6FROM docker.io/library/golang:1.26-alpine@sha256:2389ebfa5b7f43eeafbd6be0c3700cc46690ef842ad962f6c5bd6be49ed82039 AS supervisor-builder 7RUN apk --no-cache add git 8WORKDIR /build 9RUN git clone https://github.com/ochinchina/supervisord . && \ 10 git checkout 16cb640325b3a4962b2ba17d68fb5c2b1e1b6b3c 11RUN GOBIN=/usr/bin go install -ldflags "-s -w" 12 13# Build Caddy with S3 storage backend. 14FROM docker.io/library/caddy:2.11.2-builder@sha256:d4f984844fc3b867ac88fd814285a38eaaf5b3ecadb9ca1b3b0397182ef60cfe AS caddy-builder 15RUN xcaddy build ${CADDY_VERSION} \ 16 --with=github.com/ss098/certmagic-s3@v0.0.0-20250922022452-8af482af5f39 17 18# Build git-pages. 19FROM docker.io/library/golang:1.26-alpine@sha256:2389ebfa5b7f43eeafbd6be0c3700cc46690ef842ad962f6c5bd6be49ed82039 AS git-pages-builder 20RUN apk --no-cache add git 21WORKDIR /build 22COPY go.mod go.sum ./ 23RUN go mod download 24COPY *.go ./ 25COPY src/ ./src/ 26RUN go build -ldflags "-s -w" -o git-pages . 27 28# Compose git-pages and Caddy. 29FROM docker.io/library/busybox:1.37.0-musl@sha256:19b646668802469d968a05342a601e78da4322a414a7c09b1c9ee25165042138 30COPY --from=ca-certificates-builder /etc/ssl/cert.pem /etc/ssl/cert.pem 31COPY --from=supervisor-builder /usr/bin/supervisord /bin/supervisord 32COPY --from=caddy-builder /usr/bin/caddy /bin/caddy 33COPY --from=git-pages-builder /build/git-pages /bin/git-pages 34 35WORKDIR /app 36RUN mkdir /app/data 37COPY conf/supervisord.conf /app/supervisord.conf 38COPY conf/Caddyfile /app/Caddyfile 39COPY conf/config.docker.toml /app/config.toml 40 41# Caddy ports: 42EXPOSE 80/tcp 443/tcp 443/udp 43# git-pages ports: 44EXPOSE 3000/tcp 3001/tcp 3002/tcp 45 46# While the default command is to run git-pages standalone, the intended configuration 47# is to use it with Caddy and store both site data and credentials to an S3-compatible 48# object store. 49# * In a standalone configuration, the default, git-pages listens on port 3000 (http). 50# * In a combined configuration, supervisord launches both git-pages and Caddy, and 51# Caddy listens on ports 80 (http) and 443 (https). 52CMD ["git-pages"] 53# CMD ["supervisord"]