前言
-
gogs简介
- Gogs 是一款极易搭建的自助 Git 服务。
- Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自助 Git 服务。使用 Go 语言开发使得 Gogs 能够通过独立的二进制分发,并且支持 Go 语言支持的 所有平台,包括 Linux、Mac OS X、Windows 以及 ARM 平台。
- 为什么使用gogs
- gogs轻量
- gogs自带git update
- gogs操作简洁
基于docker快速搭建
- 准备数据库
- 如果之前没有数据库,可以使用docker快速部署mysql或mariadb
mkdir -p ~/mysql/data ~/mysql/logs ~/mysql/conf
docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
- 配置数据库
MariaDB [(none)]> create database gogs default character set utf8;
MariaDB [(none)]> grant all on gogs.* to ‘gogs‘@‘%‘ identified by ‘gogspass‘;
- 如果已经有docker搭建数据库,可以使用下面的方法通过docker自有的网络互通,当然简单的方法就是通过访问外网的端口使用数据库
docker network ls
docker network connect dockeronlyofficenextcloudmysql_onlyoffice gogs
docker run -itd --name=gogs -p 10022:22 -p 10080:3000 -e TZ=Asia/Shanghai -v /volume1/docker/gogs:/data gogs/gogs
gogs配置
- docker启动后基于web配置
- http://IP:10080/install
gitlab vs gogs 资源消耗
- gitlab
- gogs
配置文件查看
cat gogs/conf/app.ini
APP_NAME = Aiker Edward
RUN_USER = git
RUN_MODE = prod
[database]
DB_TYPE = mysql
HOST = mariadb:3306
NAME = gogs
USER = gogs
PASSWD = gogspass
SSL_MODE = disable
PATH = data/gogs.db
[repository]
ROOT = /data/git/gogs-repositories
[server]
DOMAIN = gogs.abc.com
HTTP_PORT = 3000
ROOT_URL = http://gogs.abc.com/
DISABLE_SSH = false
SSH_PORT = 10022
START_SSH_SERVER = false
OFFLINE_MODE = false
[mailer]
ENABLED = false
[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = true
REQUIRE_SIGNIN_VIEW = true
SHOW_REGISTRATION_BUTTON = false
[picture]
DISABLE_GRAVATAR = false
ENABLE_FEDERATED_AVATAR = true
[session]
PROVIDER = file
[log]
MODE = file
LEVEL = Info
ROOT_PATH = /data/log
[security]
INSTALL_LOCK = true # true关闭web配置向导,false打开web配置向导
SECRET_KEY = NbSgKURfSaFxcdxW
配置基于nginx ssl的反向代理
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name gogs.abc.com;
ssl_certificate /usr/syno/etc/certificate/ReverseProxy/3a2b92d0-ea43-4c88-a7a0-e8be86104850/fullchain.pem;
ssl_certificate_key /usr/syno/etc/certificate/ReverseProxy/3a2b92d0-ea43-4c88-a7a0-e8be86104850/privkey.pem;
add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload" always;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_intercept_errors on;
proxy_http_version 1.1;
proxy_pass http://localhost:10080;
}
}
这样就可以通过https+域名访问了。
原文地址:https://blog.51cto.com/m51cto/2387801
时间: 2024-10-02 14:31:24