使用gitea搭建私有git仓库
安装
使用docker安装,参考官网教程:使用 Docker 安装 - Docs (gitea.io)
新建下面的docker-compose.yml:
1version: "3"
2
3networks:
4 gitea:
5 external: false
6
7services:
8 server:
9 image: gitea/gitea:1.17.3
10 container_name: gitea
11 environment:
12 - USER_UID=6001
13 - USER_GID=6001
14 restart: always
15 networks:
16 - gitea
17 volumes:
18 - /home/git/gitea-data:/data
19 - /etc/timezone:/etc/timezone:ro
20 - /etc/localtime:/etc/localtime:ro
21 ports:
22 - "13000:3000"
23 - "22006:22"
注意最后指定的端口映射用来提供ssh和https访问暴露。中间的volumn第一行指定了挂载数据卷的位置。
需要注意,gitea官方规定不能使用root用户运行,要提前创建一个用户,并且将数据卷放在该用户可读的位置上。
配置
在gitea第一次启动时,就可以依照向导完成配置。
第一次配置完成后,如果后面想修改一些基本配置,发现在管理页面不能修改只能查看,这时要进入到挂载的数据目录下,找到gitea/conf/app.ini
文件完成修改。我的配置如下:
1APP_NAME = Claws个人仓库 | Claws Gitea
2RUN_MODE = prod
3RUN_USER = git
4
5[repository]
6ROOT = /data/git/repositories
7
8[repository.local]
9LOCAL_COPY_PATH = /data/gitea/tmp/local-repo
10
11[repository.upload]
12TEMP_PATH = /data/gitea/uploads
13
14[server]
15APP_DATA_PATH = /data/gitea
16DOMAIN = gitea.claws.top
17SSH_DOMAIN = gitea.claws.top
18HTTP_PORT = 3000
19ROOT_URL = https://gitea.claws.top/
20DISABLE_SSH = false
21SSH_PORT = 22006
22SSH_LISTEN_PORT = 22
23LFS_START_SERVER = true
24LFS_JWT_SECRET = 95qxhC_cu-PL_3HYRUbR33RCC_LlM78vFv1_vwZIDi0
25OFFLINE_MODE = false
26
27[database]
28PATH = /data/gitea/gitea.db
29DB_TYPE = sqlite3
30HOST = localhost:3306
31NAME = gitea
32USER = root
33PASSWD =
34LOG_SQL = false
35SCHEMA =
36SSL_MODE = disable
37CHARSET = utf8
38
39[indexer]
40ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve
41
42[session]
43PROVIDER_CONFIG = /data/gitea/sessions
44PROVIDER = file
45
46[picture]
47AVATAR_UPLOAD_PATH = /data/gitea/avatars
48REPOSITORY_AVATAR_UPLOAD_PATH = /data/gitea/repo-avatars
49DISABLE_GRAVATAR = false
50ENABLE_FEDERATED_AVATAR = true
51
52[attachment]
53PATH = /data/gitea/attachments
54
55[log]
56MODE = console
57LEVEL = info
58ROUTER = console
59ROOT_PATH = /data/gitea/log
60
61[security]
62INSTALL_LOCK = true
63SECRET_KEY =
64REVERSE_PROXY_LIMIT = 1
65REVERSE_PROXY_TRUSTED_PROXIES = *
66INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE2NjY0MTI3NjN9.pj-hn4Mi5tE5K1crC6M7CLsp_cN5WoLUASY3Ba32bk0
67PASSWORD_HASH_ALGO = pbkdf2
68
69[service]
70DISABLE_REGISTRATION = true
71REQUIRE_SIGNIN_VIEW = false
72REGISTER_EMAIL_CONFIRM = true
73ENABLE_NOTIFY_MAIL = true
74ALLOW_ONLY_EXTERNAL_REGISTRATION = false
75ENABLE_CAPTCHA = false
76DEFAULT_KEEP_EMAIL_PRIVATE = false
77DEFAULT_ALLOW_CREATE_ORGANIZATION = true
78DEFAULT_ENABLE_TIMETRACKING = true
79NO_REPLY_ADDRESS = noreply.localhost
80
81[lfs]
82PATH = /data/git/lfs
83
84[mailer]
85ENABLED = true
86HOST = smtp.qq.com:465
87FROM = 2821624044@qq.com
88USER = 2821624044
89PASSWD = wfwapyrbmrpidcga
90
91[openid]
92ENABLE_OPENID_SIGNIN = true
93ENABLE_OPENID_SIGNUP = false
94
95[repository.pull-request]
96DEFAULT_MERGE_STYLE = merge
97
98[repository.signing]
99DEFAULT_TRUST_MODEL = committer
在server的ssh相关配置中,SSH_PORT 指定的是显示给用户访问的ssh端口,而SSH_LISTEN_PORT 则是容器监听的端口,二者有所差别。可能还需要配置一下端口转发。