2025-02-15 15:51:50 -08:00
2025-02-15 15:51:50 -08:00
2025-02-15 15:51:50 -08:00
2025-02-15 15:51:50 -08:00
2025-02-15 15:51:50 -08:00

Gitea Docker Setup

This is a Docker Compose configuration for running Gitea with PostgreSQL, configured with HTTPS support.

Prerequisites

  • Docker Desktop for Windows
  • Docker Compose
  • A domain or DDNS service (configured to point to your server)
  • Port forwarding configured on your router (if accessing from outside your network)

Features

  • Gitea with HTTPS support
  • PostgreSQL database
  • SSH access for Git operations
  • Persistent data storage
  • Self-signed SSL certificates (can be replaced with Let's Encrypt)

Configuration

The setup includes:

Access Methods

Web Interface

  1. External Access (Internet):

  2. Local Network Access:

  3. Local Development:

Git Operations (SSH)

  • External SSH URL: ssh://git@bee8333.ddns.net:222/username/repository.git
  • Local SSH URL: ssh://git@localhost:222/username/repository.git
  • Requires port 222 forwarded on your router for external access

Getting Started

  1. Make sure Docker Desktop is running
  2. Clone this repository
  3. Open a terminal in this directory
  4. Generate SSL certificates (see SSL Certificates section)
  5. Run docker-compose up -d
  6. Access Gitea using one of the URLs above
  7. During first-time setup:
    • Database settings are pre-configured (no changes needed)
    • Domain is set to your domain name
    • SSH port is set to 222
    • HTTPS is enabled by default

SSL Certificates

You'll need to generate SSL certificates before starting the service. The certificates should be placed in ./gitea/ssl/:

  • cert.pem - The SSL certificate
  • key.pem - The private key

To generate self-signed certificates (for development/testing):

# Create the ssl directory
mkdir -p gitea/ssl

# Generate certificates using OpenSSL
docker run --rm -v ${PWD}/gitea/ssl:/ssl alpine/openssl req -x509 -nodes \
  -days 365 -newkey rsa:2048 \
  -keyout /ssl/key.pem -out /ssl/cert.pem \
  -subj "/CN=your.domain.here"

Replace your.domain.here with your actual domain name.

Security Notes:

  • Never commit SSL certificates to version control
  • Keep your private key (key.pem) secure
  • For production use, consider using Let's Encrypt certificates
  • Self-signed certificates will show browser security warnings

Stopping the Services

To stop the services, run:

docker-compose down

Data Persistence

All data is stored in Docker volumes and local directories:

  • ./gitea/ - Gitea configuration and data
    • ./gitea/ssl/ - SSL certificates
    • ./gitea/conf/ - Gitea configuration
  • Docker volumes (managed by Docker):
    • gitea-data - Gitea repositories and application data
    • postgres-data - PostgreSQL database files

Troubleshooting

  1. Cannot access externally:

    • Verify port 3000 (HTTP) and 222 (SSH) are forwarded on your router
    • Check your DDNS service is updating correctly
    • Ensure your domain points to your correct IP
  2. SSL Certificate Warnings:

    • This is normal with self-signed certificates
    • For production, consider using Let's Encrypt certificates
  3. Local Network Access:

    • If bee8333.ddns.net doesn't resolve locally, use localhost:3000 instead
    • Add an entry to your hosts file if needed
Description
No description provided
Readme 633 MiB
Languages
PowerShell 100%