使用gitea搭建git版本服务器
本文主要参看b站的视频教程,有兴趣的小伙伴可以去看一看。gitea有几种安装方式,其中基于docker应该时最简单的了。
centos 7
docker
docker-compose
安装docker
:
# 安装依赖
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
# 添加docker下载仓库
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
# 安装docker-ce
sudo yum install docker-ce
# 启动docker-ce
sudo systemctl start docker
# 验证
sudo docker --version
sudo docker run hello-world
安装docker-compse
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
# 添加到root用户的路径,否在后续在sudo docker-compose会找不到命令
sudo ln -s /usr/local/bin/docker-compose /usr/bin/
安装gitea
mkdir gitea
cd gitea
vim docker-compose.yml
其中docker-compose.yml
来自giea
的官网
version: "2"
networks:
gitea:
external: false
services:
server:
image: gitea/gitea:latest
environment:
- USER_UID=1000
- USER_GID=1000
- DB_TYPE=postgres
- DB_HOST=db:5432
- DB_NAME=gitea
- DB_USER=gitea
- DB_PASSWD=gitea
restart: always
networks:
- gitea
volumes:
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"
depends_on:
- db
db:
image: postgres:9.6
restart: always
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=gitea
- POSTGRES_DB=gitea
networks:
- gitea
volumes:
- ./postgres:/var/lib/postgresql/data
接着运行
sudo docker-compose up server
# 后台运行
sudo docker-compose up -d server