一:创建docker-compose.yml

version: "3"
# 创建mysql和gitea专用网络
networks:
  gitea:
    external: false

services:
  server:
    # 指定gitea镜像及版本
    image: gitea/gitea
    # 指定容器别名
    container_name: gitea
    # 配置容器环境变量
    environment:
      - APP_NAME="Gitea"
      - DOMAIN=192.168.6.88
      - SSH_PORT=222
      - DISABLE_SSH=true
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=mysql
      - DB_HOST=db:3306
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
    # 开机自启
    restart: always
    # 指定容器使用的网络
    networks:
      - gitea
    # 配置挂载卷
    volumes:
      - ./data:/data
      - ./etc/timezone:/etc/timezone:ro
      - ./etc/localtime:/etc/localtime:ro
    # 配置端口映射
    ports:
      - "3000:3000"
      - "222:222"
    # 指定依赖
    depends_on:
      - db
 
  db:
    image: mysql:8.0
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=gitea
      - MYSQL_DATABASE=gitea
    # 配置端口映射
    ports:
      - "3309:3306"
    networks:
      - gitea
    volumes:
      - ./mysql:/var/lib/mysql

二:创建容器并启动容器

# 启动
docker-compose up -d
# 重启
docker-compose restart
# 关闭(仅停止容器,保留容器卷)
docker-compose down
# 停止
docker-compose stop

三:Gitea配置

启动容器后使用IP+端口访问Gitea:http://your-server-ip:3000,访问后对Gitea进行配置

1:数据库设置

QQ截图20230327184843.jpg

2:一般设置

QQ截图20230327184909.jpg

3:可选设置

QQ截图20230327184925.jpg


huaweichenai
635 声望114 粉丝