Hosting With Gitea On TrueNAS
Intuition
Section titled “Intuition”Gitea on TrueNAS provides a self-hosted Git solution that gives you full control over your code repositories without relying on third-party services. TrueNAS handles persistent storage and networking, while Gitea provides the Git hosting interface. WireGuard VPN secures remote access, and the backup strategy ensures data survives hardware failures. Understanding the separation between the storage layer (TrueNAS datasets) and the application layer (Gitea container) is key to maintaining a reliable self-hosted Git infrastructure.
Procedure
Section titled “Procedure”- Since there is built in support for Gitea with TrueCharts, install Gitea using
Discover Apps. Assign a dedicated dataset (eg,mnt/pool/gitea) for persistent storage. - Set the service type to
ClusterIPusing Ingress for external access, and exposing HTTPS ports
Setup Networking
Section titled “Setup Networking”WireGuard is recommended.
- Enable WireGuard:
Network>WireGuard Peers
Common Pitfalls
Section titled “Common Pitfalls”Confusing
git resetandgit revert. Reset moves the branch pointer; revert creates a new commit that undoes changes.Forgetting to pull before pushing when working collaboratively, leading to merge conflicts.
Confusing authentication (who you are) with authorisation (what you can do) in security contexts.
Misunderstanding the difference between a stack (LIFO) and a queue (FIFO) in data structure applications.
Confusing an algorithm with a program. An algorithm is a step-by-step procedure, not its implementation in code.
Writing pseudocode that is too language-specific rather than using standard algorithmic constructs.
Persistent Storage Configuration
Section titled “Persistent Storage Configuration”- Create a dedicated dataset:
Storage > Pools > pool_name > Add Dataset(e.g.,mnt/pool/gitea). - Mount this dataset into the Gitea container at
/data. This ensures repositories, the database, and configuration survive container restarts and updates. - Set the dataset to use at least 50 GB (repositories grow quickly).
Ingress and HTTPS Setup
Section titled “Ingress and HTTPS Setup”- In the Gitea app configuration, enable Ingress and set the host name (e.g.,
git.example.com). - Use TrueNAS built-in Certificates or Traefik with Let”s Encrypt for automatic TLS certificate provisioning.
- Configure DNS to point the domain to the TrueNAS host IP.
- Verify HTTPS by navigating to
https://git.example.comin a browser.
First Repository Setup
Section titled “First Repository Setup”- Create an admin account on first login.
- Configure
app.inifor email notifications: set SMTP host, port, user, and password. - Create your first repository and push using SSH:
Terminal window git remote add origin git@git.example.com:user/repo.gitgit push -u origin main - Add SSH keys under
Settings > SSH / GPG Keys.
Backup Strategy
Section titled “Backup Strategy”- Gitea dump:
gitea dumpcreates a zip with the database, repositories, and configuration. - Scheduled tasks: Use TrueNAS
Task Managerto rungitea dumpnightly and copy the archive to a backup dataset. - Off-site replication: Configure TrueNAS cloud sync to push backups to S3-compatible storage or a remote TrueNAS instance.
WireGuard VPN Configuration
Section titled “WireGuard VPN Configuration”- Install WireGuard on the client machine.
- Add a peer entry on TrueNAS:
Network > WireGuard Peers > Addwith the client public key and allowed IPs. - On the client, configure the peer with the TrueNAS endpoint address and port.
- Verify connectivity:
ping <gitea-internal-ip>through the tunnel.
Troubleshooting
Section titled “Troubleshooting”- 502 Bad Gateway: Check that the Gitea pod is running (
kubectl get podsor TrueNAS app status). The most common cause is a misconfigured ingress pointing to the wrong port. - Cannot push via SSH: Verify the SSH port is exposed in the Gitea app settings (default 22 mapped to a host port, e.g., 30022). Ensure the firewall allows the mapped port.
- Slow performance: Increase the PostgreSQL connection pool in
app.ini(DB_MAX_OPEN_CONNS = 50). Move the database to a dedicated SSD dataset. - Repository migration: Use the Gitea admin panel
Site Administration > Repository Migrationto import repositories from GitHub, GitLab, or another Gitea instance.
Administration Tips
Section titled “Administration Tips”- User management: Restrict public registration under
Site Administration > Account Optionsto prevent unauthorized sign-ups. Use invitations or OAuth2 for controlled access. - LFS configuration: Enable Git Large File Storage in
app.iniunder[server]withLFS_START_SERVER = true. Allocate a dedicated dataset for LFS objects as they grow quickly. - Repository limits: Set
MAX_FILE_SIZE,MAX_REPO_FILES, andDEFAULT_PUSH_CREATE_PRIVATEinapp.inito prevent abuse and manage storage consumption. - CI/CD runners: Gitea Actions supports container-based CI/CD. Deploy the
act_runneras a separate container on TrueNAS and register it with the Gitea instance viaSite Administration > Actions > Runners.
Reverse Proxy and Header Configuration
Section titled “Reverse Proxy and Header Configuration”When using Traefik or Nginx as a reverse proxy in front of Gitea, set the following in app.ini under [server]:
ROOT_URL = https://git.example.com/DOMAIN = git.example.comSSH_PORT = 22PROTOCOL = httpsTraefik automatically sets X-Forwarded-For and X-Forwarded-Proto headers. If Gitea shows incorrect redirect URLs, verify these headers are passed through correctly.
Summary
Section titled “Summary”The key principles covered in this topic are linked in the sub-pages above. Focus on understanding the definitions, applying the formulas or frameworks, and evaluating strengths and limitations of each approach.
Worked Examples
Section titled “Worked Examples”Worked examples demonstrating the application of key concepts are covered in the detailed sub-pages linked above.
Cross-References
Section titled “Cross-References”- Remote Operations covers the standard Git remote commands used to interact with a self-hosted Gitea instance.
- Workflows defines team collaboration patterns that a Gitea server enables for self-hosted teams.
- Pull Requests describes the code review process that Gitea supports natively.