Extract gitweb into a separate Dockerfile and CI job
The main quire image no longer builds or includes gitweb, lighttpd,
or their runtime dependencies (highlight, libcgi-pm-perl, perl).
gitweb lives in Dockerfile.gitweb with its own build-gitweb CI job
that pushes to ghcr.io/<repo>-gitweb.

The main image now exposes port 3000 and defaults to `quire serve`.

Assisted-by: GLM-5.1 via pi
change lqvrmumolqukxmsrynupskvzpkrvrttm
commit 034fc069d3b7c28717f83841cbaa1a9de72800c8
author Alpha Chen <alpha@kejadlen.dev>
date
parent qzrvtqqu
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index efc4202..1426158 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -49,8 +49,8 @@ jobs:
     if: github.ref == 'refs/heads/main' && github.event_name == 'push'
     runs-on: ubuntu-latest
     permissions:
-      contents: write
-      packages: write
+      contents: write # create GitHub release.
+      packages: write # push container image to GHCR.
     outputs:
       version: ${{ steps.meta.outputs.version }}
     steps:
@@ -83,3 +83,38 @@ jobs:
           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           STEPS_META_OUTPUTS_VERSION: ${{ steps.meta.outputs.version }}
         run: gh release create "${STEPS_META_OUTPUTS_VERSION}" --generate-notes
+
+  build-gitweb:
+    name: Build gitweb
+    needs: test
+    if: github.ref == 'refs/heads/main' && github.event_name == 'push'
+    runs-on: ubuntu-latest
+    permissions:
+      packages: write # push container image to GHCR.
+    steps:
+      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+        with:
+          persist-credentials: false
+      - uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
+      - uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
+        with:
+          registry: ghcr.io
+          username: ${{ github.actor }}
+          password: ${{ secrets.GITHUB_TOKEN }}
+      - id: short-sha
+        run: echo "sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
+      - uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
+        id: meta
+        with:
+          images: ghcr.io/${{ github.repository }}-gitweb
+          tags: |
+            type=raw,value={{date 'YYYYMMDD'}}-${{ steps.short-sha.outputs.sha }}
+      - uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
+        with:
+          context: .
+          file: Dockerfile.gitweb
+          push: true
+          tags: ${{ steps.meta.outputs.tags }}
+          labels: ${{ steps.meta.outputs.labels }}
+          cache-from: type=gha
+          cache-to: type=gha,mode=max
diff --git a/Dockerfile b/Dockerfile
index 97a5b0e..2a9b5fb 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -26,10 +26,7 @@ RUN curl -fsSL https://github.com/git/git/archive/refs/tags/v${GIT_VERSION}.tar.
     | tar xz \
     && cd git-${GIT_VERSION} \
     && make -j$(nproc) prefix=/usr/local NO_TCLTK=1 NO_GETTEXT= \
-    && make prefix=/usr/local install \
-    && make -j$(nproc) prefix=/usr/local NO_TCLTK=1 NO_GETTEXT= gitweb \
-    && make prefix=/usr/local install-gitweb
-# TODO(vys): remove gitweb build when quire serve has its own web view
+    && make prefix=/usr/local install
 
 # Cargo-chef stage for dependency caching.
 FROM rust:1.88-trixie AS chef
@@ -65,20 +62,12 @@ FROM debian:trixie-slim
 RUN apt-get update \
     && apt-get install -y --no-install-recommends \
         ca-certificates \
-        highlight \
-        libcgi-pm-perl \
         libcurl4 \
         libexpat1 \
-        lighttpd \
-        perl \
     && rm -rf /var/lib/apt/lists/*
-# TODO(vys): highlight, lighttpd, libcgi-pm-perl, and perl are interim deps
-# for gitweb; remove all four when quire serve has its own web view.
 
 COPY --from=git-builder /usr/local/bin/git /usr/local/bin/git
 COPY --from=git-builder /usr/local/libexec/git-core/ /usr/local/libexec/git-core/
-COPY --from=git-builder /usr/local/share/gitweb/ /usr/local/share/gitweb/
-# TODO(vys): remove the gitweb COPY above with gitweb
 COPY --from=builder /build/quire /usr/local/bin/quire
 
 # Configure git hooks globally so all repos inherit the post-receive dispatch.
@@ -94,10 +83,6 @@ RUN mkdir -p /var/quire/repos /var/quire/runs
 
 WORKDIR /var/quire
 
-# TODO(vys): everything below is interim gitweb scaffolding — remove when
-# quire serve has its own web view. Restore ENTRYPOINT ["quire"] / CMD ["serve"].
-COPY conf/gitweb.conf /etc/gitweb.conf
-COPY conf/lighttpd.conf /etc/lighttpd/lighttpd.conf
-
-EXPOSE 8080
-ENTRYPOINT ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]
+EXPOSE 3000
+ENTRYPOINT ["quire"]
+CMD ["serve"]
diff --git a/Dockerfile.gitweb b/Dockerfile.gitweb
new file mode 100644
index 0000000..5172f63
--- /dev/null
+++ b/Dockerfile.gitweb
@@ -0,0 +1,56 @@
+# Gitweb image — interim web view until quire serve has its own.
+#
+# Build with: docker build -f Dockerfile.gitweb -t quire-gitweb .
+#
+# This image only contains gitweb + lighttpd. It mounts the same
+# /var/quire/repos volume as the main quire container (read-only is
+# sufficient) and serves gitweb on port 8080.
+
+ARG GIT_VERSION=2.54.0
+FROM debian:trixie-slim AS git-builder
+ARG GIT_VERSION
+
+RUN apt-get update \
+    && apt-get install -y --no-install-recommends \
+        ca-certificates \
+        curl \
+        gcc \
+        gettext \
+        libcurl4-openssl-dev \
+        libexpat1-dev \
+        libssl-dev \
+        libz-dev \
+        make \
+        perl \
+    && rm -rf /var/lib/apt/lists/*
+
+RUN curl -fsSL https://github.com/git/git/archive/refs/tags/v${GIT_VERSION}.tar.gz \
+    | tar xz \
+    && cd git-${GIT_VERSION} \
+    && make -j$(nproc) prefix=/usr/local NO_TCLTK=1 NO_GETTEXT= \
+    && make prefix=/usr/local install \
+    && make -j$(nproc) prefix=/usr/local NO_TCLTK=1 NO_GETTEXT= gitweb \
+    && make prefix=/usr/local install-gitweb
+
+FROM debian:trixie-slim
+
+RUN apt-get update \
+    && apt-get install -y --no-install-recommends \
+        ca-certificates \
+        highlight \
+        libcgi-pm-perl \
+        libcurl4 \
+        libexpat1 \
+        lighttpd \
+        perl \
+    && rm -rf /var/lib/apt/lists/*
+
+COPY --from=git-builder /usr/local/bin/git /usr/local/bin/git
+COPY --from=git-builder /usr/local/libexec/git-core/ /usr/local/libexec/git-core/
+COPY --from=git-builder /usr/local/share/gitweb/ /usr/local/share/gitweb/
+
+COPY conf/gitweb.conf /etc/gitweb.conf
+COPY conf/lighttpd.conf /etc/lighttpd/lighttpd.conf
+
+EXPOSE 8080
+ENTRYPOINT ["lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]