docker-compose 部署

version: "3.7"

services:
  postgres:
    image: postgres:latest
    container_name: postgres
    ports:
      - 5432:5432
    networks:
      - br-net-gitea
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: 123456
      POSTGRES_DB: gitea
    volumes:
      - ./postgresql:/var/lib/postgresql
      - ./data:/var/lib/postgresql/data

  gitea:
    image: gitea/gitea:1.20.5
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=192.168.1.9:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=user
      - GITEA__database__PASSWD=123456
    restart: always
    networks:
      - br-net-gitea
    volumes:
      - ./data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /home/git/.ssh/:/data/git/.ssh


    ports:
      - 3000:3000
      - "127.0.0.1:2222:22"


    depends_on:
      - postgres

  act_runner:
    image: gitea/act_runner:latest
    environment:
      - GITEA_INSTANCE_URL=http://192.168.1.9:3000
      - GITEA_RUNNER_REGISTRATION_TOKEN=Qw5Qf4A1bTENfIOQlc1NSNyFYMLp7TAtSujb5ihF
      - GITEA_RUNNER_NAME=docker_runner
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./act_runner/act_data:/data
      - ./act_runner/act_cache:/root/.cache

常见问题

首次登录web时没有创建管理员账号,如何登录

打开Gitea网页注册的第一个账号就是管理员账号。无需特殊设置。也无需找回密码。

从Github导入仓库时报错:从不允许的主机导入

打开配置文件gitea/conf/app.ini,修改以下配置:

[migrations]
ALLOW_LOCALNETWORKS    = true
ALLOWED_DOMAINS = 127.0.0.1,192.168.31.100,github.com,*.github.com
IMPORT_LOCAL_PATHS = true  ;; 导入本地仓库开关,false:设置为false,防止所有用户(包括admin)导入服务器上的本地路径。

docker-compose restart gitea重启容器。

以下修改配置文件后,需要重启容器才能生效,不再赘述。

如何开启软件包

[packages]
ENABLED = true

开启action

[actions]
ENABLED=true

error response from daemon server gave http response to https client

docker login 报错

配置/etc/docker/daemon.json

"insecure-registries": [
    "192.168.1.9:2010"
]

如何上传docker镜像到gitea制品库

# 登录你的镜像仓库,也就是你的 Gitea 服务器地址
docker login 192.168.1.9:2010

# 从官方仓库拉取一个 nginx:latest 镜像,并改名
docker pull nginx:latest
docker tag nginx:latest 192.168.1.9:2010/zhangsan/nginx:latest

# 推送镜像到 Gitea 服务器
docker push 192.168.1.9:2010/zhangsan/nginx:latest