Forgejo
Forgejo is a community-driven, self-hosted Git forge โ a soft fork of Gitea focused on sustainability, independence, and community governance. It provides Git repository hosting, issue tracking, pull requests, code review, CI/CD via Forgejo Actions (GitHub Actions compatible), container registry, package registry, and a wiki per repository. This stack deploys Forgejo 8 backed by PostgreSQL 16 for reliable data storage. Forgejo is lightweight and can run on minimal hardware while supporting thousands of repositories and users. It supports SSH access for Git operations, OAuth2/OpenID Connect authentication, webhooks, and an extensive API compatible with the Gitea ecosystem. After deployment, access the web UI on port 3000 to complete the installation wizard and create your admin account.
Included Services
forgejo
codeberg.org/forgejo/forgejo:8
Environment Variables:
postgres
postgres:16-alpine
Environment Variables:
Generated YAML
# Generated by ComposeHub (composehub.dev)
name: forgejo
services:
forgejo:
image: codeberg.org/forgejo/forgejo:8
restart: always
ports:
- 3000:3000
- 2222:22
volumes:
- forgejo_data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
environment:
USER_UID: ${USER_UID:-1000}
USER_GID: ${USER_GID:-1000}
FORGEJO__database__DB_TYPE: postgres
FORGEJO__database__HOST: postgres:5432
FORGEJO__database__NAME: ${POSTGRES_DB:-forgejo}
FORGEJO__database__USER: ${POSTGRES_USER:-forgejo}
FORGEJO__database__PASSWD: ${POSTGRES_PASSWORD:-changeme}
FORGEJO__server__ROOT_URL: ${ROOT_URL:-http://localhost:3000}
FORGEJO__server__SSH_PORT: ${SSH_PORT:-2222}
FORGEJO__server__SSH_LISTEN_PORT: "22"
networks:
- forgejo
depends_on:
postgres:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- curl -f http://localhost:3000/api/v1/version || exit 1
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
deploy:
resources:
limits:
cpus: "2.00"
memory: 1024M
reservations:
cpus: "0.25"
memory: 128M
labels:
com.composehub.description: Forgejo Git forge โ code hosting, CI/CD, and project management
postgres:
image: postgres:16-alpine
restart: always
volumes:
- forgejo_db:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${POSTGRES_DB:-forgejo}
POSTGRES_USER: ${POSTGRES_USER:-forgejo}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
networks:
- forgejo
healthcheck:
test:
- CMD-SHELL
- pg_isready -U ${POSTGRES_USER:-forgejo} -d ${POSTGRES_DB:-forgejo}
interval: 5s
timeout: 5s
retries: 10
start_period: 30s
deploy:
resources:
limits:
cpus: "1.00"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
labels:
com.composehub.description: PostgreSQL 16 database for Forgejo
networks:
forgejo:
driver: bridge
volumes:
forgejo_data:
driver: local
forgejo_db:
driver: local
Quick Info
- Services
- 2
- Networks
- 1
- Volumes
- 2
When to Use
This template is ideal for setting up a forgejo environment. All services are pre-configured with healthchecks, resource limits, and sensible defaults. Customize environment variables before deploying to production.
Tips
- Change all default passwords before deploying
- Review resource limits for your hardware
- Add a reverse proxy for production HTTPS
- Configure backup strategies for data volumes