Showcasing Forgejo self hosting utilizing Docker and Kamal
  • Ruby 65.8%
  • Shell 31.9%
  • Dockerfile 2.3%
Find a file
claude-cockpit baafe0f2d7 Pakete auf eigenes Volume: [storage.packages] PATH = /packages (#5)
Schritt S3 aus dem Plan in #4 (Kommentar 3998): Forgejos Pakete liegen künftig auf dem eigenen Hetzner-Volume `forgejo-packages`, das seit S2 auf hetzner-1 unter `/mnt/forgejo-packages` eingehängt ist.

## Änderungen

- `config/deploy.yml`: zweites Volume `/mnt/forgejo-packages/data:/packages`, Env `FORGEJO__storage_0x2E_packages__PATH: /packages`.
- `README.md`, `README.de.md`: Zeile in der Konfigurationstabelle und Abschnitt „Paketspeicher“ / „Package storage“ (Volume, fstab, `chattr +i`, Env, Bereinigungsregel).

## Belege im Quelltext (Forgejo `v15.0/forgejo`)

- `modules/setting/config_env.go:21`: `_0x2E_` wird auch klein geschrieben zu `.` dekodiert.
- `modules/setting/storage.go:166-183, 206-240`: `[storage.packages]` mit `PATH` und leerem `STORAGE_TYPE` ergibt lokalen Speicher unter genau diesem Pfad, mit und ohne `[packages]`-Abschnitt.
- `docker/root/etc/s6/gitea/setup:60-65`: `environment-to-ini` schreibt den Wert dauerhaft in `app.ini`; `chown` läuft nur auf `/data/gitea`, `/app/gitea`, `/data/git`, deshalb gehört `data` auf dem Volume schon 1000:1000 (S2).

## Wichtig: kein Deploy nach dem Merge

Ein `kamal deploy` vor dem Umzug ließe Forgejo auf ein leeres `/packages` zeigen; die Registry wäre leer, bis die Pakete kopiert sind. Ausgerollt wird erst in S4 bei gestopptem Forgejo: Pakete per `rsync` umziehen, `packages` → `packages.alt`, `kamal app boot`. Wartungsfenster nicht zwischen 02:30 und 04:00 UTC (Backup 03:00 UTC).

Refs #4

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01NfySM2XRhdFqk68Jpi63Dr
Co-authored-by: Claude <noreply@anthropic.com>
Reviewed-on: #5
2026-10-27 23:19:08 +01:00
.kamal Remove obsolete comments 2025-04-09 14:54:33 +02:00
config Pakete auf eigenes Volume: [storage.packages] PATH = /packages (#5) 2026-10-27 23:19:08 +01:00
.dockerignore project initialisation 2025-04-08 16:07:59 +02:00
.gitignore project initialisation 2025-04-08 16:07:59 +02:00
docker-compose.yml project initialisation 2025-04-08 16:07:59 +02:00
Dockerfile Upgrade Forgejo 15.0.6 -> 15.0.9, Basis-Image auf Digest 2026-09-24 14:32:52 +02:00
README.de.md Pakete auf eigenes Volume: [storage.packages] PATH = /packages (#5) 2026-10-27 23:19:08 +01:00
README.md Pakete auf eigenes Volume: [storage.packages] PATH = /packages (#5) 2026-10-27 23:19:08 +01:00

Forgejo with Kamal

A reference setup for self-hosting Forgejo using Docker and Kamal.

Deutsch

Overview

This repository demonstrates how to deploy a Forgejo instance with Kamal, including:

  • Forgejo git server with PostgreSQL backend
  • Kamal deployment with automatic SSL via kamal-proxy
  • Docker Compose alternative for local development
  • Secret management via Kamal's password manager adapter

Structure

├── Dockerfile              # Based on codeberg.org/forgejo/forgejo (version pinned there)
├── config/
│   └── deploy.yml          # Kamal deployment configuration
├── docker-compose.yml      # Local development setup
└── .kamal/
    ├── hooks/              # Sample Kamal hooks
    └── secrets             # Secret adapter configuration

Prerequisites

  • A Linux server (tested on ARM64/aarch64)
  • Docker installed on the server
  • Kamal installed locally
  • A domain with DNS pointing to the server
  • A password manager supported by Kamal (e.g. LastPass, 1Password, Bitwarden)

Deployment with Kamal

  1. Clone this repository
  2. Adjust config/deploy.yml:
    • Set your server IP under servers.web.hosts
    • Set your domain under proxy.host
    • Configure environment variables as needed
  3. Set up .env with your password manager adapter and account
  4. Store your secrets in the password manager. Kamal secret values must not contain $: Kamal substitutes $NAME even inside values fetched from the password manager and silently alters them (basecamp/kamal#1911). Generate new values with openssl rand -hex 32 or openssl rand -base64 32.
  5. Deploy:
kamal setup    # First deployment (provisions server)
kamal deploy   # Subsequent deployments

Local Development

For local development without Kamal:

cp .env.example .env   # Configure database credentials
docker compose up -d

Forgejo will be available at http://localhost:3000.

Configuration

Forgejo is configured via environment variables using the FORGEJO__section__key pattern. Key settings in config/deploy.yml:

Variable Purpose
FORGEJO__database__DB_TYPE Database type (postgres)
FORGEJO__database__HOST Database hostname
FORGEJO__repository__ENABLE_PUSH_CREATE_USER Allow push-to-create repos
FORGEJO__security__GLOBAL_TWO_FACTOR_REQUIREMENT Enforce 2FA for all users
FORGEJO__oauth2_client__ENABLE_AUTO_REGISTRATION Auto-register OAuth2 users
FORGEJO__storage_0x2E_packages__PATH Package storage ([storage.packages] PATH), see below

See Forgejo Configuration Cheat Sheet for all options.

Package storage

Forgejo's packages (container registry) live on a dedicated Hetzner volume, separate from repositories and database under /mnt/data.

Create the volume in the Hetzner Console in the server's location with mount option "manually". The console does not create a filesystem in that case. On the server:

DEV=/dev/disk/by-id/scsi-0HC_Volume_<id>
blkid "$DEV"                        # empty: no filesystem yet
mkfs.ext4 "$DEV"
mkdir /mnt/forgejo-packages
chattr +i /mnt/forgejo-packages     # empty mount point stays read-only
echo "$DEV /mnt/forgejo-packages ext4 discard,nofail,x-systemd.before=docker.service,defaults 0 0" >> /etc/fstab
systemctl daemon-reload && mount /mnt/forgejo-packages
mkdir /mnt/forgejo-packages/data && chown 1000:1000 /mnt/forgejo-packages/data
  • The subdirectory data is bound to /packages. If the volume is missing at start, Docker cannot create data inside the immutable mount point and Forgejo does not start, instead of writing packages to the root disk.
  • nofail drops the mount's ordering before local-fs.target; x-systemd.before=docker.service puts it before Docker again (ordering only, no hard dependency). The /mnt/data line carries the same option.
  • FORGEJO__storage_0x2E_packages__PATH writes PATH = /packages under [storage.packages] into app.ini permanently, so reverting also needs an edit of app.ini.
  • Old versions are removed by an owner cleanup rule (type Container, keep_count 5, remove_days 14, keep_pattern janus-gateway-arm64/.* with "Apply pattern to full package name"); the Janus digest is pinned in nextcloud/config/deploy.yml.

References