搭建gitea服务

在Docker中安装gitea

1
mkdir gitea && cd gitea && touch docker-compose.yml

在docker-compose.yml中填入下面内容

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
version: "3"

networks:
gitea:
external: false

services:
server:
image: gitea/gitea:1.16.6
container_name: gitea
environment:
- USER_UID=1001
- USER_GID=1001
- DB_TYPE=postgres
- DB_HOST=db:5432
- DB_NAME=gitea
- DB_USER=gitea
- DB_PASSWD=gitea
- GITEA_CUSTOM=/data/custom
restart: always
networks:
- gitea
volumes:
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "2222:22"
depends_on:
- db

db:
image: postgres:14
restart: always
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=gitea
- POSTGRES_DB=gitea
networks:
- gitea
volumes:
- ./postgres:/var/lib/postgresql/data

最后执行

1
docker-compose up -d

gitea即安装完成,然后访问localhost:3000 即可开启gitea之旅。在主页填写好地址,邮箱,用户等信息即可。

可以把3000端口映射到公网443端口,绑定好域名

另外把2222端口绑定到公网22端口,即可(官网有ssh和gitea复用22端口的方法,我尝试没有成功。但我通过路由器UPnP端口转发搞定了22端口)