Skip to content

Instantly share code, notes, and snippets.

@tarivs
Last active March 12, 2017 11:47
Show Gist options
  • Save tarivs/fc4ac5b5fd590bab6739984c10343206 to your computer and use it in GitHub Desktop.
Save tarivs/fc4ac5b5fd590bab6739984c10343206 to your computer and use it in GitHub Desktop.
Deploy your own git server in ten minutes

十分钟部署自己的git服务器

本教材适用于Ubuntu,Debian,Centos等大部分Linux By Tarivs

安装dockers

利用daocloud的安装脚本一键完成docker安装,详见https://get.daocloud.io/

curl -sSL https://get.daocloud.io/docker | sh

创建文件目录

mkdir -p /data/gogs
mkdir -p /data/mysql

创建 nginx proxy

修改mysql_passwd为自己的mysql密码

docker run --name nginx_proxy -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy

创建mysql

修改mysql_passwd为自己的mysql密码

docker run --name mysql -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mysql_passwd -d mysql:5.7

mysql 库

新建mysql用户:gogs,密码:gogs

docker exec -t -i mysql /bin/bash
mysql -u root -p
create database  gogs;
CREATE USER gogs IDENTIFIED BY 'gogs';
GRANT ALL PRIVILEGES ON gogs.* TO gogs;

启动gogs

修改git.xxx.com为自己的访问域名

docker run -e VIRTUAL_HOST=git.xxx.com -e VIRTUAL_PORT=3000 --name=gogs --link mysql:db  -p 10022:22 -v /data/gogs:/data gogs/gogs
docker start gogs

初始化gogs

打开git.xxx.com

mysql 服务器地址:http://db:3306
用户名:gogs
密码:gogs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment