Gitea
Self-hosted Git service with Docker and PostgreSQL.
Gitea
Introduction
Gitea is a lightweight, self-hosted Git service written in Go. This guide will walk you through setting up Gitea with Docker and PostgreSQL using docker-compose
.
Setting Up Gitea with Docker
Create a Directory
1
mkdir gitea && cd gitea
Create docker-compose.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
services:
server:
image: docker.io/gitea/gitea:latest
container_name: gitea
environment:
- USER_UID=1000
- USER_GID=1000
restart: unless-stopped
volumes:
- ./gitea/data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
Start Gitea
1
docker-compose up -d
Installation
After starting the Docker setup, open your browser and visit http://server-ip:3000
to complete the installation via the web UI.
Customization
Customization files should be placed in the gitea/data
directory as described in the official documentation.
Modify app.ini
:
1
nano ./gitea/data/conf/app.ini
Example:
1
2
[server]
DISABLE_REGISTRATION = true # Disables registration so only admins can create accounts.
Restart Gitea for changes to take effect:
1
docker restart gitea
Setting Up a Runner (Optional)
To enable CI/CD workflows using Gitea Actions, set up a runner:
1
2
3
4
5
docker run -e GITEA_INSTANCE_URL=https://gitea.example.com \
-e GITEA_RUNNER_REGISTRATION_TOKEN=<your_token> \
-v /var/run/docker.sock:/var/run/docker.sock \
--name my_runner \
gitea/act_runner:nightly
Verify the runner is registered:
1
docker logs my_runner
Conclusion
You now have a self-hosted Git service running with Gitea, PostgreSQL, and optional CI/CD support. Happy coding!
This post is licensed under
CC BY 4.0
by the author.