phabricator: Upgrade Phorge to 2026.27 and build from php:8.4-apache.

The former base image ghcr.io/datenknoten/phorge is no longer maintained
(its source repository is gone).  Build our own image from the official
PHP image instead, with Phorge and arcanist pinned to the stable branch
heads.  Use the Recreate strategy because the data volume is RWO.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Change-Id: I3ea4f00d8202ec125866ab5ddfcfce8b2e752425
diff --git a/phabricator/Dockerfile b/phabricator/Dockerfile
new file mode 100644
index 0000000..78c8944
--- /dev/null
+++ b/phabricator/Dockerfile
@@ -0,0 +1,107 @@
+# Phorge, built from the official PHP image.
+#
+# Based on the Dockerfile of the former ghcr.io/datenknoten/phorge image
+# (github.com/phorge-docker/phorge, no longer available).
+#
+# To upgrade, set PHORGE_REF and ARCANIST_REF to the current heads of the
+# stable branches:
+#
+#   git ls-remote https://we.phorge.it/source/phorge.git refs/heads/stable
+#   git ls-remote https://we.phorge.it/source/arcanist.git refs/heads/stable
+
+FROM php:8.4-apache-trixie
+
+# Phorge 2026.27 (stable)
+ARG PHORGE_REF=7d2dd8899c3b31bfd7a61d8e0de94b9b9a675615
+ARG ARCANIST_REF=34b8b54e0a01a2622acea78b0b9ca82b45141f98
+
+RUN apt-get update \
+  && apt-get install -y --no-install-recommends \
+    git \
+    mercurial \
+    subversion \
+    ca-certificates \
+    python3-pygments \
+    imagemagick \
+    openssh-client \
+    openssh-server \
+    procps \
+    sudo \
+  && rm -rf /var/lib/apt/lists/*
+
+RUN set -ex; \
+    a2enmod rewrite; \
+    savedAptMark="$(apt-mark showmanual)"; \
+    apt-get update; \
+    apt-get install -y --no-install-recommends \
+      libonig-dev \
+      libcurl4-openssl-dev \
+      libjpeg62-turbo-dev \
+      libpng-dev \
+      libfreetype-dev \
+      libzip-dev \
+    ; \
+    docker-php-ext-configure gd --with-jpeg --with-freetype; \
+    docker-php-ext-install -j "$(nproc)" \
+      gd \
+      opcache \
+      mbstring \
+      iconv \
+      mysqli \
+      curl \
+      pcntl \
+      zip \
+    ; \
+    pecl install apcu; \
+    docker-php-ext-enable apcu; \
+    apt-mark auto '.*' > /dev/null; \
+    apt-mark manual $savedAptMark; \
+    ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
+      | awk '/=>/ { print $3 }' \
+      | sort -u \
+      | xargs -r realpath \
+      | xargs -r dpkg-query -S \
+      | cut -d: -f1 \
+      | sort -u \
+      | xargs -rt apt-mark manual; \
+    apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
+    rm -rf /var/lib/apt/lists/* /tmp/pear
+
+RUN { \
+      echo 'opcache.memory_consumption=128'; \
+      echo 'opcache.interned_strings_buffer=8'; \
+      echo 'opcache.max_accelerated_files=4000'; \
+      echo 'opcache.revalidate_freq=60'; \
+      echo 'opcache.validate_timestamps=0'; \
+    } > /usr/local/etc/php/conf.d/opcache-recommended.ini \
+  && echo 'date.timezone="UTC"' > /usr/local/etc/php/conf.d/timezone.ini \
+  && { \
+      echo 'post_max_size=32M'; \
+      echo 'upload_max_filesize=32M'; \
+    } > /usr/local/etc/php/conf.d/uploads.ini
+
+RUN mkdir /var/repo && chown www-data:www-data /var/repo
+
+RUN git clone https://we.phorge.it/source/arcanist.git /opt/arcanist \
+  && git -C /opt/arcanist checkout --detach "$ARCANIST_REF" \
+  && git clone https://we.phorge.it/source/phorge.git /opt/phorge \
+  && git -C /opt/phorge checkout --detach "$PHORGE_REF"
+
+WORKDIR /opt/phorge
+
+RUN rmdir /var/www/html \
+  && ln -sf /opt/phorge/webroot /var/www/html \
+  && { \
+      echo '<VirtualHost *:80>'; \
+      echo '  RewriteEngine on'; \
+      echo '  RewriteRule ^(.*)$ /index.php?__path__=$1 [B,L,QSA]'; \
+      echo '</VirtualHost>'; \
+    } > /etc/apache2/sites-available/000-default.conf
+
+COPY sudoers /etc/sudoers
+ENV PATH="$PATH:/opt/phorge/bin:/var/www/phorge/bin"
+
+RUN ln -s phorge /var/lib/phabricator
+
+RUN ln -s /opt/phorge /var/www/phorge
+RUN ln -s phorge /var/www/phabricator
diff --git a/phabricator/phabricator.yaml b/phabricator/phabricator.yaml
new file mode 100644
index 0000000..db9ee94
--- /dev/null
+++ b/phabricator/phabricator.yaml
@@ -0,0 +1,184 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: phabricator
+  namespace: mulk
+spec:
+  selector:
+    matchLabels:
+      k8s-app: phabricator
+  replicas: 1
+  strategy:
+    type: Recreate
+  template:
+    metadata:
+      labels:
+        k8s-app: phabricator
+    spec:
+      initContainers:
+        - name: storage-upgrade
+          image: docker.benkard.de/mulk/phabricator:8
+          command:
+            - /opt/phorge/bin/storage
+            - upgrade
+            - --force
+          volumeMounts:
+            - mountPath: /tmp
+              name: temp
+            - mountPath: /var/tmp
+              name: vartemp
+            - mountPath: /var/repo
+              name: data
+              subPath: repo
+            - mountPath: /var/lib/phorge
+              name: data
+              subPath: data
+            - mountPath: /opt/phorge/conf/local
+              name: data
+              subPath: conf/local
+            - mountPath: /opt/phorge/support/preamble.php
+              name: data
+              subPath: preamble.php
+          resources:
+            requests:
+              cpu: "0"
+              memory: "0"
+            limits:
+              cpu: "2"
+              memory: "1G"
+      containers:
+        - name: master
+          image: docker.benkard.de/mulk/phabricator:8
+          volumeMounts:
+            - mountPath: /tmp
+              name: temp
+            - mountPath: /var/tmp
+              name: vartemp
+            - mountPath: /var/repo
+              name: data
+              subPath: repo
+            - mountPath: /var/lib/phorge
+              name: data
+              subPath: data
+            - mountPath: /opt/phorge/conf/local
+              name: data
+              subPath: conf/local
+            - mountPath: /opt/phorge/support/preamble.php
+              name: data
+              subPath: preamble.php
+          resources:
+            requests:
+              cpu: "0"
+              memory: "0"
+            limits:
+              cpu: "2"
+              memory: "1G"
+          ports:
+            - containerPort: 80
+              protocol: TCP
+              name: http
+        - name: phd
+          image: docker.benkard.de/mulk/phabricator:8
+          command:
+            - bash
+            - -c
+            - "phd start && tail -f /var/tmp/phd/log/daemons.log"
+          volumeMounts:
+            - mountPath: /tmp
+              name: temp
+            - mountPath: /var/tmp
+              name: vartemp
+            - mountPath: /var/repo
+              name: data
+              subPath: repo
+            - mountPath: /var/lib/phorge
+              name: data
+              subPath: data
+            - mountPath: /opt/phorge/conf/local
+              name: data
+              subPath: conf/local
+          resources:
+            requests:
+              cpu: "0"
+              memory: "0"
+            limits:
+              cpu: "2"
+              memory: "512M"
+      volumes:
+        - name: temp
+          emptyDir: {}
+        - name: vartemp
+          emptyDir: {}
+        - name: data
+          persistentVolumeClaim:
+            claimName: phabricator-data
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: phabricator-data
+  namespace: mulk
+  labels:
+    storage: phabricator-data
+spec:
+  accessModes:
+    - ReadWriteOnce
+  resources:
+    requests:
+      storage: 20Gi
+  storageClassName: local-path
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: phabricator
+  namespace: mulk
+spec:
+  selector:
+    k8s-app: phabricator
+  ports:
+  - name: default
+    protocol: TCP
+    port: 80
+    targetPort: http
+  clusterIP: None
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: phabricator
+  namespace: mulk
+  annotations:
+    cert-manager.io/cluster-issuer: letsencrypt-prod
+    kubernetes.io/ingress.class: nginx
+    traefik.ingress.kubernetes.io/preserve-host: "true"
+    traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip
+    ingress.kubernetes.io/ssl-proxy-headers: X-Forwarded-Proto:https
+    ingress.kubernetes.io/custom-request-headers: X-Forwarded-Proto:https||X-Forwarded-Port:443
+spec:
+  rules:
+  - host: phabricator.benkard.de
+    http:
+      paths:
+      - path: /
+        pathType: ImplementationSpecific
+        backend:
+          service:
+            name: phabricator
+            port:
+              number: 80
+  - host: ph-user.benkard.de
+    http:
+      paths:
+      - path: /
+        pathType: ImplementationSpecific
+        backend:
+          service:
+            name: phabricator
+            port:
+              number: 80
+  tls:
+  - hosts:
+    - phabricator.benkard.de
+    - ph-user.benkard.de
+    secretName: phabricator-tls
diff --git a/phabricator/sudoers b/phabricator/sudoers
new file mode 100644
index 0000000..499d77f
--- /dev/null
+++ b/phabricator/sudoers
@@ -0,0 +1,2 @@
+www-data ALL=(root) SETENV: NOPASSWD: /usr/bin/git
+www-data ALL=(root) SETENV: NOPASSWD: /usr/lib/git-core/git-http-backend