[mirror] Scalable static site server for Git forges (like GitHub Pages)

Cache individual layers of Docker container as it is being built.

Unfortunately this is still not enough to fit into codeberg-medium :(

+13 -12
+10 -6
.forgejo/workflows/ci.yaml
··· 5 5 pull_request: 6 6 workflow_dispatch: 7 7 8 + env: 9 + FORGE: codeberg.org 10 + 8 11 jobs: 9 12 check: 10 13 runs-on: codeberg-small-lazy ··· 79 82 apt-get -y install buildah ca-certificates 80 83 - name: Check out source code 81 84 uses: https://code.forgejo.org/actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 85 + - name: Authenticate with Docker 86 + run: | 87 + buildah login --authfile=/tmp/authfile-${FORGE}.json \ 88 + -u ${{ vars.PACKAGES_USER }} -p ${{ secrets.PACKAGES_TOKEN }} ${FORGE} 82 89 - name: Build container 83 90 run: | 84 91 printf '[storage]\ndriver="vfs"\nrunroot="/run/containers/storage"\ngraphroot="/var/lib/containers/storage"\n' | tee /etc/containers/storage.conf 85 - buildah build --arch=amd64 --tag=container:${VER}-amd64 . 86 - buildah build --arch=arm64 --tag=container:${VER}-arm64 . 92 + buildah build ${CACHE} --arch=amd64 --tag=container:${VER}-amd64 93 + buildah build ${CACHE} --arch=arm64 --tag=container:${VER}-arm64 87 94 buildah manifest create container:${VER} \ 88 95 container:${VER}-amd64 \ 89 96 container:${VER}-arm64 90 97 env: 91 98 BUILDAH_ISOLATION: chroot 92 99 VER: ${{ startsWith(forge.event.ref, 'refs/tags/v') && forge.ref_name || 'latest' }} 100 + CACHE: ${{ format('--authfile=/tmp/authfile-{0}.json --layers --cache-from {0}/{1}/cache --cache-to {0}/{1}/cache', env.FORGE, forge.repository) }} 93 101 - if: ${{ forge.repository == 'git-pages/git-pages' }} 94 102 name: Push container to Codeberg 95 103 run: | 96 - buildah login --authfile=/tmp/authfile-${FORGE}.json \ 97 - -u ${{ vars.PACKAGES_USER }} -p ${{ secrets.PACKAGES_TOKEN }} ${FORGE} 98 104 buildah manifest push --authfile=/tmp/authfile-${FORGE}.json \ 99 105 --all container:${VER} "docker://${FORGE}/${{ forge.repository }}:${VER/v/}" 100 106 env: 101 - BUILDAH_ISOLATION: chroot 102 - FORGE: codeberg.org 103 107 VER: ${{ startsWith(forge.event.ref, 'refs/tags/v') && forge.ref_name || 'latest' }}
+3 -6
Dockerfile
··· 8 8 WORKDIR /build 9 9 RUN git clone https://github.com/ochinchina/supervisord . && \ 10 10 git checkout 16cb640325b3a4962b2ba17d68fb5c2b1e1b6b3c 11 - RUN GOBIN=/usr/bin go install -ldflags "-s -w" && \ 12 - go clean -cache -modcache 11 + RUN GOBIN=/usr/bin go install -ldflags "-s -w" 13 12 14 13 # Build Caddy with S3 storage backend. 15 14 FROM docker.io/library/caddy:2.10.2-builder@sha256:6e3ed727ce8695fc58e0a8de8e5d11888f6463c430ea5b40e0b5f679ab734868 AS caddy-builder 16 15 RUN xcaddy build ${CADDY_VERSION} \ 17 - --with=github.com/ss098/certmagic-s3@v0.0.0-20250922022452-8af482af5f39 && \ 18 - go clean -cache -modcache 16 + --with=github.com/ss098/certmagic-s3@v0.0.0-20250922022452-8af482af5f39 19 17 20 18 # Build git-pages. 21 19 FROM docker.io/library/golang:1.25-alpine@sha256:d3f0cf7723f3429e3f9ed846243970b20a2de7bae6a5b66fc5914e228d831bbb AS git-pages-builder ··· 25 23 RUN go mod download 26 24 COPY *.go ./ 27 25 COPY src/ ./src/ 28 - RUN go build -ldflags "-s -w" -o git-pages . && \ 29 - go clean -cache -modcache 26 + RUN go build -ldflags "-s -w" -o git-pages . 30 27 31 28 # Compose git-pages and Caddy. 32 29 FROM docker.io/library/busybox:1.37.0-musl@sha256:ef13e7482851632be3faf5bd1d28d4727c0810901d564b35416f309975a12a30