前言
使用docker+gogs方式搭建自己的私有代码服务器
Gogs官网文档地址
创建docker mysql
[mysqld]
skip-host-cache
skip-name-resolve
[mysql]
default-character-set = utf8
[mysql_safe]
default-character-set = utf8
[client]
default-character-set = utf8
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
#log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
#bind-address = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# 修改mysql默认字符集
init_connect = 'SET NAMES utf8'
character-set-server = utf8
collation-server = utf8_unicode_ci
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
创建 docker gogs
docker pull gogs/gogsmkdir /opt/docker/gogsdocker run -d --name=mygogs -p 10022:22 -p 10080:3000 -v /opt/docker/gogs:/data gogs/gogsdocker start mygogsdocker rm mygogsdocker exec -it mygogs /bin/bash
gogs配置
http://192.168.3.61:10080/
/opt/docker/gogs/gogs/log
docker操作
docker ps -adocker logs --tail=200 gogs-mysqldocker logs -f gogs-mysql
安装完成
http://192.168.3.61:10080即可操作
域名访问gogs项目
设置nginx配置,保存信息,重启nginx服务
server {
listen 80;
server_name 域名信息;
#方向代理 gogs访问
location / {
proxy_pass http://127.0.0.1:10080/;
proxy_redirect default;
}
#access_log /var/log/nginx/gogs/access.log main;
#error_log /var/log/nginx/gogs/error.log;
}
修改gogs配置
[server]
DOMAIN = sudo docker exec -it mysql /bin/bash
HTTP_PORT = 3000
ROOT_URL = 上一步更改的域名信息
DISABLE_SSH = false
SSH_PORT = 10022
START_SSH_SERVER = false
OFFLINE_MODE = false
重启gogs,即可访问