Files
gitea-docker/README.md
2025-02-15 15:51:50 -08:00

129 lines
3.9 KiB
Markdown

# 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
1. **External Access (Internet)**:
- URL: https://bee8333.ddns.net/
- Requires port 3000 forwarded on your router
- Uses HTTPS with SSL certificate
2. **Local Network Access**:
- Same URL: https://bee8333.ddns.net/
- Or use: https://localhost:3000
- Both use HTTPS with SSL certificate
- No port forwarding needed
3. **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
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](#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):
```bash
# 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:
```bash
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