Skip to main content

Overview

Gitea is a lightweight, self-hosted Git service that provides repository management, issue tracking, and CI/CD integration through Woodpecker CI. This document covers the deployment and configuration of Gitea using Docker Compose with Traefik as a reverse proxy.

Service Details

Architecture

The deployment consists of:
  1. Gitea Server: The main application container running the Git service
  2. PostgreSQL Database: Persistent storage for all Gitea data
  3. Traefik Integration: Handles routing, SSL termination, and SSH proxying

Prerequisites

  • Docker Engine (24.0+)
  • Docker Compose v2
  • Traefik reverse proxy configured and running
  • External networks: gitea-net and traefik-net
  • SSH entrypoint configured in Traefik
  • DNS configured for git.trymondo.com

Deployment Configuration

Environment Variables

Create a .env file with the following variables:
Never commit the .env file to version control. Store passwords securely in a password manager.

Docker Compose File

Network Configuration

Before deployment, ensure the required networks exist:

Deployment Instructions

  1. Create the deployment directory:
  2. Create the docker-compose.yml and .env files:
  3. Deploy the service:
  4. Verify the service is running:

Traefik Integration Details

HTTP Routing

Gitea’s web interface is available through HTTPS:
  • Host Rule: git.trymondo.com
  • Entrypoint: websecure (HTTPS)
  • TLS: Enabled with production certificate resolver
  • Backend Port: 3000

SSH Routing

Git SSH operations are handled through Traefik’s TCP router:
  • Rule: HostSNI(*) - accepts all hostnames for SSH
  • Entrypoint: ssh (TCP port typically 2222)
  • Service: gitea-ssh
  • Backend Port: 2222
Users will need to configure their Git client to use port 2222 for SSH operations: git clone ssh://git@git.trymondo.com:2222/username/repo.git

Initial Configuration

After deploying Gitea, complete the setup through the web interface:
  1. Access https://git.trymondo.com in your browser
  2. You’ll be redirected to the installation page
  3. Configure the following settings:

Database Settings

  • Database Type: PostgreSQL (pre-configured)
  • Host: db:5432 (pre-configured)
  • Username: gitea (pre-configured)
  • Password: [value from .env file] (pre-configured)
  • Database Name: gitea (pre-configured)

Application General Settings

  • Site Title: GitMondo (recommended)
  • Repository Root Path: /var/lib/gitea/repositories (default)
  • Git LFS Root Path: /var/lib/gitea/lfs (default)
  • Run As Username: git (default)
  • SSH Server Domain: git.trymondo.com
  • SSH Server Port: 2222
  • Gitea HTTP Listen Port: 3000 (default)
  • Gitea Base URL: https://git.trymondo.com/
  • Log Path: /var/lib/gitea/log (default)

Email Settings (Optional)

  • SMTP Host: smtp.mailersend.net
  • SMTP Port: 587
  • From Email: info@trymondo.com
  • SMTP Username: [your SMTP username]
  • SMTP Password: [your SMTP password]

Administrator Account

  • Create an initial administrator account with secure credentials

Maintenance

Backup Strategy

Back up Gitea regularly using the following steps:
  1. Stop the Gitea container (keep the database running):
  2. Back up volumes:
  3. Restart Gitea:
Consider using Backrest to automate regular backups of Gitea’s volumes.

Updates

To update Gitea:
  1. Update the image tag in docker-compose.yml
  2. Apply the update:
  3. Check logs for any issues:

Troubleshooting

Database Connection Issues

If Gitea can’t connect to the database:
  1. Verify PostgreSQL container is running:
  2. Check database logs:
  3. Test database connection:

SSH Connection Problems

If Git SSH operations fail:
  1. Verify Traefik is properly routing SSH traffic:
  2. Check Gitea’s SSH settings:
  3. Verify user’s SSH configuration:

Monitoring

Gitea and its database have Diun labels for container update monitoring:

Additional Resources

Integration with CI/CD

For CI/CD integration with Woodpecker CI, see the DevOps Stack documentation.