TFGrid Gitea Guide¶
Self-hosted Git service with web interface - perfect for AI agent repositories and team collaboration.
Overview¶
TFGrid Gitea provides a lightweight, self-hosted Git service similar to GitHub but running on your ThreeFold Grid infrastructure. Ideal for storing code generated by tfgrid-ai-agent, private repositories, and team collaboration.
Features¶
- ð Self-hosted - Your code, your infrastructure, full control
- ð Web Interface - GitHub-like UI for browsing repos and managing projects
- ð User Management - Multiple users, organizations, and teams
- ð Issues & PRs - Built-in issue tracking and pull requests
- ð API Access - Full RESTful API for automation
- ðŠķ Lightweight - Runs efficiently on 2 cores, 2GB RAM
- ð Secure - Keep your code private on decentralized infrastructure
Quick Deployment¶
Option 1: Standalone Deployment¶
# Deploy Gitea on single VM
tfgrid-compose up tfgrid-gitea
# Get access information
tfgrid-compose address tfgrid-gitea
# Access at: http://<vm-ip>:3000
Option 2: With Gateway (Recommended)¶
Deploy Gitea behind a gateway for SSL and custom domain:
# Deploy with gateway pattern
tfgrid-compose up tfgrid-gitea --pattern gateway --domain example.com
# Access at: https://example.com/gitea
Option 3: Full AI Dev Stack¶
Deploy AI agent + Gateway + Gitea together:
# Complete integrated workflow
tfgrid-compose up ai-gateway-stack --domain example.com
# Access:
# - example.com/gitea â Gitea UI
# - example.com/website1 â AI-generated sites
Default Credentials¶
â ïļ Important: Change these immediately after first login!
- Username:
gitadmin
- Password:
changeme123
- Email:
admin@localhost
Changing Admin Password¶
- Login to Gitea web interface
- Click your avatar â Settings
- Navigate to Account â Change Password
- Save new password
Using with AI Agent¶
Perfect companion for tfgrid-ai-agent - automatically store generated code in Gitea:
Setup Git Remote¶
# SSH to AI agent VM
tfgrid-compose ssh ai-gateway-stack --vm ai-agent
# Configure git
git config --global user.name "AI Agent"
git config --global user.email "ai@example.com"
# Create and push project
cd /home/developer/code
mkdir my-website && cd my-website
git init
git remote add origin http://example.com/gitea/gitadmin/my-website.git
git add .
git commit -m "Initial commit"
git push -u origin main
Automated Workflow¶
Coming in v0.11.0 - AI agent automatically: 1. Creates code 2. Pushes to Gitea (example.com/gitea/repos/projectname) 3. Deploys to gateway (example.com/projectname) 4. Complete visibility of all changes
API Usage¶
Gitea provides a full RESTful API for automation:
Generate API Token¶
- Login to Gitea
- Settings â Applications
- Generate New Token
- Copy token (shown only once!)
API Examples¶
# Create repository
curl -X POST "http://example.com/gitea/api/v1/user/repos" \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"new-repo","description":"My new repository","private":false}'
# List repositories
curl "http://example.com/gitea/api/v1/user/repos" \
-H "Authorization: token YOUR_TOKEN"
# Get repository info
curl "http://example.com/gitea/api/v1/repos/gitadmin/my-repo" \
-H "Authorization: token YOUR_TOKEN"
# Create issue
curl -X POST "http://example.com/gitea/api/v1/repos/gitadmin/my-repo/issues" \
-H "Authorization: token YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title":"Bug found","body":"Description of the bug"}'
Full API docs available at: http://your-gitea/api/swagger
Configuration¶
Custom Settings¶
Set environment variables before deployment:
export GITEA_ADMIN_USER=myadmin
export GITEA_ADMIN_PASSWORD=mysecurepassword
export GITEA_ADMIN_EMAIL=admin@example.com
export GITEA_DOMAIN=example.com
export GITEA_PORT=3000
tfgrid-compose up tfgrid-gitea
Resource Requirements¶
Minimum: - 2 CPU cores - 2 GB RAM - 25 GB disk
Recommended: - 2 CPU cores - 4 GB RAM - 50 GB disk (for multiple large repos)
Gateway Integration¶
When deployed with the gateway pattern, Gitea is automatically proxied:
# Gateway automatically configures nginx:
location /gitea/ {
proxy_pass http://gitea-vm:3000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Benefits:
- SSL/TLS encryption via Let's Encrypt
- Custom domain support
- No port specification needed
- Professional URL: https://example.com/gitea
User Management¶
Creating Users¶
Via Web UI: 1. Login as admin 2. Site Administration â User Accounts 3. Create New Account 4. Fill in details and save
Via CLI:
# SSH to Gitea VM
tfgrid-compose ssh tfgrid-gitea
# Create user
su - git -c "gitea admin user create \
--username newuser \
--password secretpass \
--email user@example.com \
--config /etc/gitea/app.ini"
Organizations¶
- Click + icon â New Organization
- Fill in organization details
- Add members and set permissions
- Create repos under organization
Backup & Restore¶
Backup¶
# SSH to Gitea VM
tfgrid-compose ssh tfgrid-gitea
# Create backup
sudo tar -czf /tmp/gitea-backup-$(date +%Y%m%d).tar.gz \
/var/lib/gitea/data \
/etc/gitea
# Download backup
exit
scp root@<gitea-ip>:/tmp/gitea-backup-*.tar.gz ./
Restore¶
# Upload backup to new VM
scp gitea-backup-*.tar.gz root@<new-gitea-ip>:/tmp/
# SSH to new VM
tfgrid-compose ssh tfgrid-gitea
# Stop service
sudo systemctl stop gitea
# Restore
sudo tar -xzf /tmp/gitea-backup-*.tar.gz -C /
# Fix permissions
sudo chown -R git:git /var/lib/gitea
sudo chown -R git:git /etc/gitea
# Start service
sudo systemctl start gitea
Troubleshooting¶
Service Not Starting¶
# Check service status
systemctl status gitea
# View logs
journalctl -u gitea -f
# Check configuration
sudo -u git /usr/local/bin/gitea doctor --config /etc/gitea/app.ini
# Restart service
systemctl restart gitea
Can't Access Web Interface¶
# Check if port is listening
netstat -tuln | grep 3000
# Test local connection
curl http://localhost:3000
# Check firewall (if using standalone)
ufw status
ufw allow 3000/tcp
Database Issues¶
# Check database file
ls -lh /var/lib/gitea/data/gitea.db
# Check permissions
ls -ld /var/lib/gitea/data
# Should be owned by git:git
# Repair if needed
sudo -u git sqlite3 /var/lib/gitea/data/gitea.db "PRAGMA integrity_check;"
Performance Issues¶
For large repositories:
-
Increase resources in tfgrid-compose.yaml:
-
Redeploy:
Security Best Practices¶
Essential Security Steps¶
- Change default password immediately
- Enable 2FA (Settings â Security â Two-Factor Authentication)
- Use strong passwords for all accounts
- Disable registration if not needed (app.ini:
DISABLE_REGISTRATION = true
) - Regular backups of /var/lib/gitea/data
- Keep updated - monitor Gitea releases
SSL/TLS¶
Always deploy behind a gateway with SSL in production:
This provides: - â Free Let's Encrypt SSL certificates - â Automatic HTTPS redirect - â Certificate auto-renewal
Advanced Usage¶
Webhooks¶
Configure webhooks to trigger actions on push:
- Repository â Settings â Webhooks
- Add Webhook
- Set URL (e.g., https://example.com/deploy-hook)
- Select events (push, pull request, etc.)
- Save
Use case: Auto-deploy to gateway when AI agent pushes code.
Git LFS¶
For large files (>100MB):
# Install git-lfs on client
git lfs install
# Track large files
git lfs track "*.psd"
git lfs track "*.zip"
# Commit and push as normal
git add .
git commit -m "Add large files"
git push
Mirror Repositories¶
Mirror external repos to Gitea:
- New Migration â GitHub/GitLab/etc.
- Enter source URL
- Configure mirror settings
- Gitea will sync automatically
Next Steps¶
- AI Agent Guide - Use AI agent with Gitea
- Gateway Pattern - Deploy with SSL
- App Registry - Explore more apps
- Gitea Official Docs - Full Gitea documentation
Support¶
- TFGrid Docs: https://docs.tfgrid.studio
- Gitea Docs: https://docs.gitea.com
- GitHub Issues: https://github.com/tfgrid-studio/tfgrid-gitea/issues
- Discussions: https://github.com/orgs/tfgrid-studio/discussions
Made with ðĨ for decentralized development
TFGrid Studio Ecosystem
Integrated tools and resources