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