dcc2dda7695b6ab4915704e16cbc6b30826808bc
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:
- Gitea web interface:
- External access: https://bee8333.ddns.net/
- Local network access: https://bee8333.ddns.net/ or https://localhost:3000
- Local development: https://127.0.0.1:3000
- SSH access on port 222 (for git clone/push/pull)
- PostgreSQL database (internal access only)
- SSL certificates in
./gitea/ssl/ - Persistent data storage for both Gitea and PostgreSQL
Access Methods
Web Interface
-
External Access (Internet):
- URL: https://bee8333.ddns.net/
- Requires port 3000 forwarded on your router
- Uses HTTPS with SSL certificate
-
Local Network Access:
- Same URL: https://bee8333.ddns.net/
- Or use: https://localhost:3000
- Both use HTTPS with SSL certificate
- No port forwarding needed
-
Local Development:
- URL: https://127.0.0.1:3000
- Direct access on the hosting machine
- Uses HTTPS with SSL certificate
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
- Make sure Docker Desktop is running
- Clone this repository
- Open a terminal in this directory
- Generate SSL certificates (see SSL Certificates section)
- Run
docker-compose up -d - Access Gitea using one of the URLs above
- 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 certificatekey.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 datapostgres-data- PostgreSQL database files
Troubleshooting
-
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
-
SSL Certificate Warnings:
- This is normal with self-signed certificates
- For production, consider using Let's Encrypt certificates
-
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
Languages
PowerShell
100%