Setting Up Private Github With Gitea
Setting up a private Git repository is very useful for creating personal projects and having full control of source code creation. Gitea is a very useful utility with a clean interface resembling Github. If you want to try test out Gitea follow this Link.
Linux Installation:
-
Make sure Docker and Docker Compose are installed and setup. Guide
-
Create a directory for Gitea.
mkdir -p /home/(username)/docker/gitea
- Configure docker-compose.yml for Gitea server.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#docker-compose.yml
version: "2"
services:
gitea:
image: gitea/gitea:1.11.5 #update and or change if outdated
container_name: gitea
ports:
- 3000:3000
environment:
- USER_UID=1000 #change accordingly
- USER_GID=1000 #change accordingly
- DB_TYPE=mysql
- DB_HOST=db:3306
- DB_NAME=gitea
- DB_USER=gitea
- DB_PASSWD= #set password to match db
- ROOT_URL= #set url with http/https://
restart: always
networks:
- gitea
# labels: #optional Traefik configuration
# - "traefik.enable=true"
# - "traefik.http.routers.gitea-web.rule=Host(`(domain)`)" #replace (domain) with domain
# - "traefik.http.routers.gitea-web.tls=true"
# - "traefik.http.routers.gitea-web.tls.certresolver=letsencrypt"
# - "traefik.http.services.gitea-web.loadbalancer.server.port=3000"
volumes:
- gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
depends_on:
- db
db:
image: mariadb:latest
restart: always
# labels: #optional Traefik configuration
# - "traefik.enable=false"
environment:
- MYSQL_ROOT_PASSWORD= #set root user password
- MYSQL_USER=gitea
- MYSQL_PASSWORD= #set gitea user password
- MYSQL_DATABASE=gitea
networks:
- gitea
volumes:
- db:/var/lib/mysql
networks:
gitea:
external: false
volumes:
gitea:
db:
|
-
Go to url and configure admin user and site settings.
-
Additional Gitea configuration is found inside the container volume. Disable registration is highly recommended.
sudo vim /var/lib/docker/volumes/(volume name should resemble gitea)/_data/gitea/conf/app.ini
docker-compose down
docker-compose up -d
-
Make sure that container is rebuilt after every configuration change.
-
Create regular users with admin user if registration is disabled.
-
Gitea should be good to go and updates can easily be applied by editing gitea image in docker-compose.yml and docker-compose pull.