Showcasing Forgejo self hosting utilizing Docker and Kamal
- Ruby 65.8%
- Shell 31.9%
- Dockerfile 2.3%
Security: 15.0.8 (Announcement #59) und 15.0.9 (#60) schliessen je eine Critical-RCE (Template-Generierung, ApplyDiffPatch), einen Token-Scope-Bypass, den Zugriff auf Anhaenge von Draft-Releases und eine OpenID-CSRF. Einzige Migration seit 15.0.6 stammt aus 15.0.7. Cooldown erfuellt (17.09.). Vorgaenger: localhost:5556/arndttouby/forgejo@sha256:c79287ce6499ebcc3020614f98712bde45c588c7cfb765816608396073fd3ea7 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .kamal | ||
| config | ||
| .dockerignore | ||
| .gitignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| README.de.md | ||
| README.md | ||
Forgejo with Kamal
A reference setup for self-hosting Forgejo using Docker and Kamal.
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
- Clone this repository
- Adjust
config/deploy.yml:- Set your server IP under
servers.web.hosts - Set your domain under
proxy.host - Configure environment variables as needed
- Set your server IP under
- Set up
.envwith your password manager adapter and account - Store your secrets in the password manager
- 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 |
See Forgejo Configuration Cheat Sheet for all options.