Gitea
Lightweight, self-hosted Git service with a beautiful interface, built-in CI/CD, and painless setup.
Overview
Gitea is a lightweight, self-hosted Git service written in Go that provides a GitHub-like interface for managing Git repositories. Born from a fork of Gogs in 2016, Gitea focuses on being painless to install and run while offering comprehensive features including pull requests, issue tracking, wiki pages, and built-in CI/CD through Gitea Actions. Its minimal resource requirements and straightforward setup make it an ideal choice for teams wanting private Git hosting without the complexity of larger platforms. This deployment configuration creates a robust Git hosting environment using two containerized services: the Gitea application server and a dedicated PostgreSQL database for data persistence. The setup leverages PostgreSQL's reliability and performance for storing repository metadata, user accounts, issues, and configuration data, while the Gitea container handles the web interface, Git operations, and SSH access. The two services communicate over a dedicated Docker network, with Gitea configured to automatically connect to PostgreSQL on startup. This combination provides excellent performance and reliability for teams requiring private code repositories with enterprise-grade database backing. The stack is particularly valuable for development teams, DevOps engineers, and organizations seeking complete control over their source code management while maintaining GitHub-like functionality and user experience.
Key Features
- GitHub-like web interface with repository browsing, file editing, and commit history visualization
- Built-in CI/CD through Gitea Actions with GitHub Actions compatibility for existing workflows
- Comprehensive issue tracking system with labels, milestones, and project boards for agile development
- Pull request workflow with code review, inline comments, and merge conflict resolution
- PostgreSQL backend providing ACID compliance and robust data integrity for all Git metadata
- SSH Git access on port 222 alongside HTTPS for flexible repository cloning and pushing
- Package registry support for Docker, npm, PyPI, and other package formats
- Repository migration tools for importing from GitHub, GitLab, and other Git services
Common Use Cases
- 1Private Git hosting for software development teams requiring code privacy and control
- 2DevOps environments needing integrated CI/CD pipelines with GitHub Actions compatibility
- 3Educational institutions providing Git services for programming courses and student projects
- 4Open source project hosting for communities wanting self-managed infrastructure
- 5Enterprise development teams migrating from cloud Git services to on-premises solutions
- 6Homelab environments for personal project management and portfolio development
- 7Compliance-sensitive organizations requiring air-gapped or geographically restricted code hosting
Prerequisites
- Docker and Docker Compose installed on the host system
- Minimum 768MB RAM available (256MB for PostgreSQL, 512MB for Gitea application)
- Ports 3000 (HTTP) and 222 (SSH) available and not conflicting with existing services
- DB_PASSWORD environment variable configured in .env file or system environment
- Basic understanding of Git operations and repository management concepts
- SSH client configured if using SSH-based Git operations on port 222
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 gitea: 3 image: gitea/gitea:latest4 container_name: gitea5 restart: unless-stopped6 environment: 7 USER_UID: 10008 USER_GID: 10009 GITEA__database__DB_TYPE: postgres10 GITEA__database__HOST: db:543211 GITEA__database__NAME: gitea12 GITEA__database__USER: gitea13 GITEA__database__PASSWD: ${DB_PASSWORD}14 volumes: 15 - gitea_data:/data16 ports: 17 - "3000:3000"18 - "222:22"19 depends_on: 20 - db2122 db: 23 image: postgres:15-alpine24 container_name: gitea-db25 environment: 26 POSTGRES_USER: gitea27 POSTGRES_PASSWORD: ${DB_PASSWORD}28 POSTGRES_DB: gitea29 volumes: 30 - gitea_db:/var/lib/postgresql/data3132volumes: 33 gitea_data: 34 gitea_db: .env Template
.env
1DB_PASSWORD=changemeUsage Notes
- 1Docs: https://docs.gitea.io/
- 2Access at http://localhost:3000 - setup wizard on first visit
- 3SSH clone: git clone ssh://git@localhost:222/user/repo.git
- 4First registered user becomes admin
- 5Gitea Actions for built-in CI/CD (GitHub Actions compatible)
- 6Package registry, issue tracker, wiki included
Individual Services(2 services)
Copy individual services to mix and match with your existing compose files.
gitea
gitea:
image: gitea/gitea:latest
container_name: gitea
restart: unless-stopped
environment:
USER_UID: 1000
USER_GID: 1000
GITEA__database__DB_TYPE: postgres
GITEA__database__HOST: db:5432
GITEA__database__NAME: gitea
GITEA__database__USER: gitea
GITEA__database__PASSWD: ${DB_PASSWORD}
volumes:
- gitea_data:/data
ports:
- "3000:3000"
- "222:22"
depends_on:
- db
db
db:
image: postgres:15-alpine
container_name: gitea-db
environment:
POSTGRES_USER: gitea
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_DB: gitea
volumes:
- gitea_db:/var/lib/postgresql/data
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 gitea:5 image: gitea/gitea:latest6 container_name: gitea7 restart: unless-stopped8 environment:9 USER_UID: 100010 USER_GID: 100011 GITEA__database__DB_TYPE: postgres12 GITEA__database__HOST: db:543213 GITEA__database__NAME: gitea14 GITEA__database__USER: gitea15 GITEA__database__PASSWD: ${DB_PASSWORD}16 volumes:17 - gitea_data:/data18 ports:19 - "3000:3000"20 - "222:22"21 depends_on:22 - db2324 db:25 image: postgres:15-alpine26 container_name: gitea-db27 environment:28 POSTGRES_USER: gitea29 POSTGRES_PASSWORD: ${DB_PASSWORD}30 POSTGRES_DB: gitea31 volumes:32 - gitea_db:/var/lib/postgresql/data3334volumes:35 gitea_data:36 gitea_db:37EOF3839# 2. Create the .env file40cat > .env << 'EOF'41DB_PASSWORD=changeme42EOF4344# 3. Start the services45docker compose up -d4647# 4. View logs48docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/gitea/run | bashTroubleshooting
- Gitea shows database connection error: Verify DB_PASSWORD environment variable matches between gitea and db services, check that db container is running and healthy
- SSH Git clone fails on port 222: Ensure port 222 is not blocked by firewall and SSH daemon inside Gitea container is running, verify SSH keys are properly configured in Gitea web interface
- First user registration fails: Check that gitea_data volume has proper write permissions for UID/GID 1000, restart gitea container if database initialization is incomplete
- Gitea Actions workflows not triggering: Verify Gitea Actions is enabled in site administration settings and runners are properly registered and online
- PostgreSQL container fails to start: Check available disk space for gitea_db volume and ensure no other PostgreSQL instances are conflicting with container startup
- Web interface returns 502 Bad Gateway: Confirm gitea container started successfully after database connection was established, check container logs for application startup errors
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Ad Space
Shortcuts: C CopyF FavoriteD Download