forgejo

by QuenchWorks

Helm chartv0.0.26App 15.0.12GPL-3.0-or-laterVerified publisher

Self-hosted Git forge (Forgejo, a community Gitea fork; Go + embedded web UI). Hardened by QuenchWorks as a minimal, nonroot, CVE-gated image, cosign-signed and pinned by digest.

About this chart

Quenchworks forgejo

Hardened Forgejo, a self-hosted Git forge and community Gitea fork, on a minimal, nonroot, CVE-gated image pinned by digest and cosign-signed (keyless / Sigstore). Single node; it persists its repositories, SQLite database and generated config to a PVC, and boots install-locked so the web installer is never served.

Install

helm install my-forgejo oci://ghcr.io/quenchworks/charts/forgejo

Then port-forward and open the web UI:

kubectl port-forward svc/my-forgejo-forgejo 3000:80
# http://127.0.0.1:3000

Set the external URL (behind an ingress) and open ingress to clients outside the release namespace:

helm install my-forgejo oci://ghcr.io/quenchworks/charts/forgejo \
  --set config.rootUrl=https://git.example.com/ \
  --set networkPolicy.allowExternal=true

Verify the image

cosign verify ghcr.io/quenchworks/images/forgejo \
  --certificate-identity-regexp 'https://github.com/quenchworks/.+' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

Each build also ships an SPDX SBOM and SLSA provenance attestation. Verify them with gh attestation verify oci://ghcr.io/quenchworks/images/forgejo --owner quenchworks.

Values

KeyDefaultNotes
image.repositoryghcr.io/quenchworks/images/forgejo
image.digest(CI-written)Required. Charts pin by digest, never a tag.
image.pullPolicyIfNotPresentAlways, IfNotPresent, or Never.
nameOverride""Override the chart name in resource names.
replicaCount1Stateful single node (SQLite); do not scale out.
containerPort3000HTTP port Forgejo binds (nonroot). Wired to server.HTTP_PORT.
config.appNameForgejoInstance name.
config.rootUrl""External base URL (set behind an ingress). Defaults to http://localhost:<containerPort>/.
config.logLevelinfoConsole log level.
config.ssh.enabledfalseBuilt-in git-over-SSH server; exposes an ssh service port when on.
config.ssh.port22
service.typeClusterIPClusterIP, NodePort, or LoadBalancer.
service.port80Service port, forwards to the container's http port.
service.httpsPort443Service port for the TLS listener (container 8443) when tls.enabled.
tls.enabledfalseServe the web UI and API over HTTPS on the app's own listener; the certificate is mounted at /tls.
tls.existingSecret""Use this kubernetes.io/tls Secret (1st choice).
tls.certManager.enabledfalseRequest a cert-manager Certificate from tls.certManager.issuerRef (2nd choice).
tls.selfSigned.validityDays365Otherwise Helm generates a CA + certificate, kept across upgrades.
persistence.enabledtruePVC mounted at mountPath (repos + DB + config).
persistence.mountPath/dataForgejo work/data dir.
persistence.size8GiRequested volume size.
persistence.storageClass""Default class if unset.
persistence.accessModes["ReadWriteOnce"]PVC access modes.
persistence.existingClaim""Bind an existing PVC instead of provisioning one.
resources.requests100m / 128MiCPU / memory requests.
resources.limits1 / 512MiCPU / memory limits.
serviceAccount.createtrueToken automount is off.
serviceAccount.name""Use an existing ServiceAccount if set.
rbac.createfalseMinimal empty Role/RoleBinding when enabled.
networkPolicy.enabledtrueRestricts client ingress to the release namespace.
networkPolicy.allowExternalfalseSet true to allow ingress from any source.
podDisruptionBudget.enabledtrueminAvailable: 1.
ingress.enabledfalseCreate an Ingress. With tls.enabled it routes to 443: set the backend protocol to HTTPS.
ingress.className""IngressClass to claim it. Empty leaves it unset, so the cluster default applies.
ingress.annotations{}Controller annotations (rewrite targets, body size, cert-manager issuer, ...).
ingress.servicePortnullBackend port. Unset: service.httpsPort with tls.enabled, else service.port.
ingress.hosts[]e.g. [{host: app.example.com}]. A host with no paths gets a single / Prefix path.
ingress.tls[]Standard Ingress TLS list, e.g. [{hosts: [app.example.com], secretName: app-tls}].

Plus the shared quench-common knobs: podLabels, podAnnotations, nodeSelector, affinity, tolerations, topologySpreadConstraints, priorityClassName, schedulerName, terminationGracePeriodSeconds, updateStrategy, extraEnvVars, extraEnvVarsCM, extraEnvVarsSecret, extraVolumes, extraVolumeMounts, initContainers, sidecars, lifecycleHooks, command, args, podSecurityContext, containerSecurityContext, and the probe overrides (livenessProbe, readinessProbe, startupProbe, and their customLivenessProbe/customReadinessProbe/customStartupProbe replacements).

PostgreSQL, Valkey and the first administrator

By default Forgejo keeps SQLite on the data volume. For an existing PostgreSQL and a Valkey (or Redis) for cache, sessions and queues:

database:
  type: postgres
  postgres: { host: pg-postgresql:5432, name: forgejo, user: forgejo, existingSecret: forgejo-db, passwordKey: password }
redis:
  enabled: true
  host: valkey:6379
  existingSecret: forgejo-valkey
  passwordKey: password
admin:
  username: root
  email: [email protected]
  existingSecret: forgejo-admin   # key: password

These are written into app.ini on the first boot only, like the rest of the seeded config. The administrator is created with forgejo admin user create after migrating the database, and the init container retries it on every boot until it exists (for a database that was not ready on the first one).

Architecture

Forgejo runs as a single-replica StatefulSet. Everything lives locally: a SQLite database, a repository tree, and the generated app.ini, all on one PVC mounted at persistence.mountPath (/data) via a volumeClaimTemplate. Because state is local it cannot be horizontally scaled, so replicaCount is capped at 1.

The container runs nonroot (uid 1001) on a read-only root filesystem with all capabilities dropped; only the /data PVC and an emptyDir /tmp are writable. Forgejo serves /api/healthz (returns {"status":"pass",...}), which backs the startup, liveness and readiness probes.

The hardened image runs forgejo web directly and has no environment-to-ini step, so FORGEJO__* env vars are not honored. Instead an init container generates an app.ini on the PVC on first boot, containing:

  • INSTALL_LOCK = true, which skips the web installer
  • SECRET_KEY, INTERNAL_TOKEN and oauth2.JWT_SECRET, generated by the forgejo binary itself (real, valid values) and persisted on the PVC, so they never touch the read-only root filesystem and never rotate on restart
  • a SQLite DB at <mountPath>/forgejo.db, repos under <mountPath>/git/repositories

The file is written only if absent, so restarts and upgrades keep your data and secrets. To change non-secret settings, edit config.* in values.

Configuration examples

Registration is open by default. Create the first admin non-interactively:

kubectl exec -it my-forgejo-forgejo-0 -- \
  forgejo --config /data/app.ini admin user create \
  --admin --username admin --password 'change-me' --email [email protected]

Serve behind an ingress on a larger volume, with git-over-SSH enabled:

config:
  rootUrl: https://git.example.com/
  ssh:
    enabled: true
    port: 22
persistence:
  size: 20Gi
  storageClass: fast-ssd

When SSH is enabled you must also expose the SSH port through the service/ingress yourself.

Uninstall

helm uninstall my-forgejo

The PVC provisioned by the StatefulSet's volumeClaimTemplate is retained on uninstall. Delete it explicitly to remove the repositories, database and secrets:

kubectl delete pvc -l app.kubernetes.io/instance=my-forgejo

Notes

Single node only: Forgejo stores everything in a local SQLite database plus a repository tree on the PVC, so it cannot be horizontally scaled. For HA you would move to an external database and shared storage, tracked as a follow-up. The chart depends on the quench-common library chart, pulled from oci://ghcr.io/quenchworks/charts/quench-common.

Deploy forgejo with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has forgejo on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartforgejo is pinned at v0.0.26 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply