2026-02-25 16:53:27 +03:00
2026-02-02 20:02:18 +03:00
2026-02-02 20:02:18 +03:00
2026-02-02 20:02:18 +03:00
2026-02-02 20:02:18 +03:00
2026-02-25 16:53:27 +03:00
2026-02-02 19:58:01 +03:00
2026-02-02 19:58:01 +03:00
2026-02-02 19:58:01 +03:00

Gitea Docker Setup

Self-hosted Git service with Docker Compose and SSL certificates for production deployment. Database is managed separately.

Quick Start

Local Development

  1. Copy the local environment configuration:
cp .env.local .env
  1. Update .env with your database connection details (ensure database is running):
nano .env
# Update DB_HOST, DB_USER, DB_PASSWORD
  1. Start Gitea:
docker-compose up -d
  1. Access Gitea at http://localhost:3000

Production Deployment (repos.guschin.info)

  1. Copy the production environment configuration:
cp .env.production .env
  1. IMPORTANT: Edit .env and update the database credentials:
nano .env
# Update DB_HOST, DB_USER, DB_PASSWORD with your external database connection
  1. IMPORTANT: Ensure the MySQL database is running and accessible before starting Gitea

  2. Install SSL certificates:

./install-certificates.sh
  1. Start Gitea:
docker-compose up -d

Configuration Files

  • docker-compose.yml - Docker Compose configuration for Gitea only
  • .env - Active environment configuration (gitignored)
  • .env.local - Local development settings
  • .env.production - Production environment settings
  • install-certificates.sh - SSL certificate installation for production

Environment Variables

Database Configuration (External)

  • DB_HOST - MySQL host (e.g., db-server.example.com:3306)
  • DB_NAME - Database name (default: gitea)
  • DB_USER - Database user (default: gitea)
  • DB_PASSWORD - Database password (ensure it's secure!)

Gitea Configuration

  • GITEA_DOMAIN - Domain name (localhost or repos.guschin.info)
  • GITEA_ROOT_URL - Full URL to Gitea instance
  • GITEA_HTTP_PORT - HTTP port mapping (default: 3000)
  • GITEA_SSH_PORT - SSH port mapping (default: 2222 for local, 22 for production)

Common Commands

# Start Gitea
docker-compose up -d

# Stop Gitea
docker-compose down

# View logs
docker-compose logs -f gitea

# Restart Gitea
docker-compose restart gitea

# Check service status
docker-compose ps

Database Backup/Restore: Use commands on the external database server, not in docker-compose.

SSL Certificates

The install-certificates.sh script will:

  1. Install certbot if not present
  2. Obtain Let's Encrypt SSL certificates for repos.guschin.info
  3. Configure automatic certificate renewal
  4. Copy certificates to ./certs directory

Certificates are automatically renewed every 60 days.

Volumes

  • gitea-data - Gitea application data and repositories

Security Notes

  1. Always change default passwords in production
  2. Use strong passwords for database credentials
  3. Keep the .env file secure (it's gitignored by default)
  4. Regularly update Docker images: docker-compose pull && docker-compose up -d
  5. Enable 2FA for Gitea admin accounts

Ports

  • Local: HTTP on 3000, SSH on 2222
  • Production: HTTP on 3000 (behind reverse proxy), SSH on 22

Troubleshooting

Database connection issues

Ensure the external database is running and accessible with the credentials in .env. Test the connection:

mysql -h ${DB_HOST} -u ${DB_USER} -p

Certificate issues

# Test certificate renewal
sudo certbot renew --dry-run

# Check certificate expiry
sudo certbot certificates

Permission issues

# Fix volume permissions
docker-compose down
sudo chown -R 1000:1000 ./volumes/gitea-data
docker-compose up -d
Description
No description provided
Readme 32 KiB
Languages
Shell 100%