docker-compose 创建轻量级git服务——gitea

烂漫一生 提交于 2020-02-28 17:23:27

docker-compose.yml

version: '2'
services:
  web:
    image: gitea/gitea:1.6
    container_name: gitea_web
    hostname: gitea.trio.ai
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=mysql
      - DB_HOST=db:3306
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=password
      - RUN_MODE=prod
      - LANGS=zh-CN
    networks:
      - gitea
    volumes:
      - data:/data
      - /etc/localtime:/etc/localtime
    ports:
      - "3000:3000"
      - "3022:22"
    depends_on:
      - db
    restart: always
  db:
    image: mysql:5.7
    container_name: gitea_db
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=password
      - MYSQL_DATABASE=gitea
    networks:
      - gitea
    volumes:
      - db:/var/lib/mysql
      - conf:/etc/mysql
      - /etc/localtime:/etc/localtime
volumes:
  data:
  db:
  conf:
networks:
  gitea:
    external: false

 

gitea配置文件:

cat /data/gitea/conf/app.ini

 

APP_NAME = 标题
RUN_MODE = prod
RUN_USER = git     #默认属性

[repository]
ROOT = /data/git/repositories   #默认属性
DEFAULT_PRIVATE = private  #默认属性
DISABLE_HTTP_GIT = true   #禁用http的git
USE_COMPAT_SSH_URI = true  #git ssh时 添加ssh://    

[repository.local]
LOCAL_COPY_PATH = /data/gitea/tmp/local-repo   #默认属性

[repository.upload]
TEMP_PATH = /data/gitea/uploads  #默认属性

[server]
APP_DATA_PATH = /data/gitea  #默认属性
SSH_DOMAIN = gitea.example.com  #填写用来访问的域名
HTTP_PORT = 3000          #默认端口
ROOT_URL = http://gitea.example.com/   #填写用来访问的域名
DISABLE_SSH = false        #默认属性
SSH_PORT = 3022          #这里写的是docker外部端口而非内部22端口,改这里docker内部22端口不会改变,需要改/etc/ssh/sshd_config 文件,内部端口才会改变
LFS_CONTENT_PATH = /data/git/lfs  #默认属性
DOMAIN = gitea.example.com    #外部显示的域名
LFS_START_SERVER = true  #默认属性
LFS_JWT_SECRET =     #默认属性
OFFLINE_MODE = false    #默认属性

[database]
PATH = /data/gitea/gitea.db  #默认属性
DB_TYPE = mysql      #mysql
HOST = db:3306      #docker-compose启动时,启动两个容器,默认两个容器可以互相访问,使用创建时db名称,容器会自动寻找相应db容器
NAME = gitea      #数据库
USER = gitea      #用户
PASSWD = PASSWORD    #密码
SSL_MODE = disable      #是否启用ssl

[indexer]
ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve    #默认

[session]
PROVIDER_CONFIG = /data/gitea/sessions  #默认
PROVIDER = file      #默认

[picture]
AVATAR_UPLOAD_PATH = /data/gitea/avatars  #默认
DISABLE_GRAVATAR = false        #默认
ENABLE_FEDERATED_AVATAR = true    #默认

[attachment]
PATH = /data/gitea/attachments      #默认

[log]
ROOT_PATH = /data/gitea/log    #默认
MODE = file              #默认
LEVEL = Info        #默认

[security]
INSTALL_LOCK = true        #默认
SECRET_KEY =         #默认
INTERNAL_TOKEN =     #默认

[service]
DISABLE_REGISTRATION = true      #默认
REQUIRE_SIGNIN_VIEW = true      #默认
REGISTER_EMAIL_CONFIRM = true      #默认
ENABLE_NOTIFY_MAIL = true      #默认
ALLOW_ONLY_EXTERNAL_REGISTRATION = false    #默认
ENABLE_CAPTCHA = false                #默认
DEFAULT_KEEP_EMAIL_PRIVATE = false        #默认
DEFAULT_ALLOW_CREATE_ORGANIZATION = true      #默认
DEFAULT_ENABLE_TIMETRACKING = true      #默认
NO_REPLY_ADDRESS =           #默认

[mailer]
ENABLED = true        #默认
HOST = smtp.gitea.io:465    #可填端口 25,465,587
FROM = test@gitea.io      
USER =  test@gitea.io
PASSWD = PASSWORD

[openid]
ENABLE_OPENID_SIGNIN = true    #默认
ENABLE_OPENID_SIGNUP = false    #默认

 

 

NOTE:

mysql 创建时注意修改字符集utf8,否则不识别中文输入。修改配置文件后,删除数据库,重新docker-compose一次

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!