Gitea Git Server
A lightweight, self-hosted Git service powered by Gitea and backed by PostgreSQL 16 for reliable data storage. Gitea provides a GitHub-like experience including repository management, issue tracking, pull requests, CI/CD via Gitea Actions, and a built-in container registry. The web UI is exposed on port 3000 and SSH access for Git operations is available on port 2222. PostgreSQL is tuned for the moderate query patterns of a Git hosting platform, with health checks ensuring the database is ready before Gitea starts. All repositories, LFS objects, and configuration are persisted in named volumes, making backup and migration straightforward.
Included Services
gitea
gitea/gitea:1.22
Environment Variables:
postgres
postgres:16-alpine
Environment Variables:
Generated YAML
# Generated by ComposeHub (composehub.dev)
name: gitea-postgres
services:
gitea:
image: gitea/gitea:1.22
restart: unless-stopped
ports:
- 3000:3000
- 2222:22
volumes:
- gitea_data:/data
- gitea_config:/data/gitea/conf
environment:
GITEA__database__DB_TYPE: postgres
GITEA__database__HOST: postgres:5432
GITEA__database__NAME: ${POSTGRES_DB:-gitea}
GITEA__database__USER: ${POSTGRES_USER:-gitea}
GITEA__database__PASSWD: ${POSTGRES_PASSWORD:-changeme}
GITEA__server__DOMAIN: ${GITEA_DOMAIN:-localhost}
GITEA__server__ROOT_URL: ${GITEA_ROOT_URL:-http://localhost:3000}
GITEA__server__SSH_DOMAIN: ${GITEA_SSH_DOMAIN:-localhost}
GITEA__server__SSH_PORT: "2222"
GITEA__server__LFS_START_SERVER: "true"
GITEA__service__DISABLE_REGISTRATION: ${GITEA_DISABLE_REGISTRATION:-false}
GITEA__service__REQUIRE_SIGNIN_VIEW: ${GITEA_REQUIRE_SIGNIN:-false}
GITEA__mailer__ENABLED: ${GITEA_MAILER_ENABLED:-false}
GITEA__mailer__SMTP_ADDR: ${GITEA_SMTP_ADDR:-}
GITEA__mailer__SMTP_PORT: ${GITEA_SMTP_PORT:-587}
GITEA__mailer__FROM: ${GITEA_MAIL_FROM:[email protected]}
USER_UID: "1000"
USER_GID: "1000"
networks:
- frontend
- backend
depends_on:
postgres:
condition: service_healthy
healthcheck:
test:
- CMD-SHELL
- curl -f http://localhost:3000/api/healthz || exit 1
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: "1.00"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
labels:
com.composeforge.description: Gitea self-hosted Git service
postgres:
image: postgres:16-alpine
restart: unless-stopped
command:
- postgres
- "-c"
- shared_buffers=128MB
- "-c"
- effective_cache_size=384MB
- "-c"
- work_mem=8MB
- "-c"
- max_connections=50
volumes:
- postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: ${POSTGRES_DB:-gitea}
POSTGRES_USER: ${POSTGRES_USER:-gitea}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_INITDB_ARGS: "--encoding=UTF-8 --lc-collate=C --lc-ctype=C"
networks:
- backend
healthcheck:
test:
- CMD-SHELL
- pg_isready -U ${POSTGRES_USER:-gitea} -d ${POSTGRES_DB:-gitea}
interval: 15s
timeout: 5s
retries: 5
start_period: 30s
deploy:
resources:
limits:
cpus: "1.00"
memory: 512M
reservations:
cpus: "0.25"
memory: 128M
labels:
com.composeforge.description: PostgreSQL 16 database for Gitea
networks:
frontend:
driver: bridge
backend:
driver: bridge
volumes:
gitea_data:
driver: local
gitea_config:
driver: local
postgres_data:
driver: local
Quick Info
- Services
- 2
- Networks
- 2
- Volumes
- 3
When to Use
This template is ideal for setting up a gitea git server 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