Gogs搭建自己的git服务器

来自linux中国网wiki
跳到导航 跳到搜索

官网

https://gogs.io/

Docker for Gogs

母机
192.168.50.159

参考命令这里-d将容器跑到后台,不在当前终端输出
#docker run --name=jenkins -it -u root -d -p 8080:8080 -p 50000:50000 -v /data/jenkins:/var/jenkins_home 3f08dc4f3f5d

# Pull image from Docker Hub.
$ docker pull gogs/gogs

# Create local directory for volume. 物理机数据目录
$ mkdir -p /var/gogs

# Use `docker run` for the first time.
$ docker run --name=gogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs

# Use `docker start` if you have stopped it. 以后启动用这个命令就行了
$ docker start gogs

docker exec -it gogs /bin/bash

http://192.168.50.159:10080/install
#用sqlite3 直接配置就行了,如果想要mysql 得自己搞一下喽 改为真实地址可以 pull push 但是不好看呢


域名 应用 URL 这些要改 为
192.168.50.159:10080

clone 

git clone ssh://git@hostname:10022/username/myrepo.git

#注意  就是有很多地方 像新建的仓库地址显示为localhost 这个得改一下  还有 key 添加 无论在project 还是用户 哪里添加 都还是要密码 是glone 要指定用户名么 

参考

https://github.com/gogs/gogs/tree/master/docker

使用Docker搭建git服务Gogs

使用Docker部署Nginx + Gogs快速搭建在线Git服务

Docker部署(四):Gogs

helm gogs

下载二进制包

数据库相关操作

#不用创建库 mysql -uroot -pevan < scripts/mysql.sql

create user 'gogs'@'localhost' identified by 'evan';
 create user 'gogs'@'127.0.0.1' identified by 'evan';
 grant all privileges on gogs.* to 'gogs'@'localhost' identified by "evan";
 grant all privileges on gogs.* to 'gogs'@'127.0.0.1' identified by "evan";
 flush privileges;
 exit;

创建git 用户

useradd git ; passwd git 

 



配置启动文件

cp scripts/init/centos/gogs /etc/init.d/ 
#GOGS_HOME=/data/gogs/gogs 
sed -i 's#GOGS_HOME=/home/git/gogs#GOGS_HOME=/data/gogs/#' /etc/init.d/gogs 

mkdir -p /data/gogs/log;

chmod +x /etc/init.d/gogs
chown -R git:git /data/gogs/;

/etc/init.d/gogs start 
#./gogs web



web 界面安装

 mkdir -p /data/gogs-repositories && chown -R git:git /data/gogs-repositories

http://192.168.3.9:3000/install
ip:3000;

web 界面安装中要注意的 

仓库根目录  /data/gogs-repositories


服务器和其它服务设置 禁止用户自主注册 
启用登录访问限制


常见问题

官方常见问题