docker-compose 部署 gitea

下载源

yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

安装docker

yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

启动docker

systemctl start docker.service

设置自启

systemctl enable docker.service

下载docker-compose

curl -L https://get.daocloud.io/docker/compose/releases/download/v2.5.1/docker-compose-`uname -s`-`uname -m` > /usr/local/docker-compose

设置执行权限

chmod +x /usr/local/docker-compose

配置文件

vi /usr/local/docker-compose.yaml

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:latest
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "222:22"

默认用的数据库是sqlite3

启动gitea

/usr/local/docker-compose -f /usr/local/docker-compose.yaml up -d

查看是否正确启动

/usr/local/docker-compose -f /usr/local/docker-compose.yaml ps

访问WEB对gitea进行首次配置

http://x.x.x.x:3000/

 

gitea备份

先将gitea所在目录增加权限,我为了方便给了777

chmod -R 777 /usr/local/gitea/

进入到gitea镜像中

docker exec -it gitea /bin/sh

su git

cd /data

开始备份

gitea dump

gitea恢复

备份出来的文件如下

将data目录下的所有文件夹放到 /usr/local/gitea/gitea

将repos目录下的所有文件夹放到 /usr/local/gitea/git/repositories

再次设置权限

chmod -R 777 /usr/local/gitea/

重启一下

/usr/local/docker-compose -f /usr/local/docker-compose.yaml restart

 

posted @ 2022-05-24 16:24  缤纷世界  阅读(18)  评论(0编辑  收藏  举报