gitea mysql_使用gitea创建自家的git服务

本文介绍了如何在家庭内网环境中使用Docker和MySQL搭建Gitea,作为个人的git服务。通过安装Ubuntu Server虚拟机,配置Docker和docker-compose,然后设置Gitea的环境变量,最后完成初始化并设置访问控制,实现类似GitHub的功能。
摘要由CSDN通过智能技术生成

在家庭内网创建一个ci/cd环境,保存一些资料和代码,并部署应用。其实最初是准备上gitlab的,一个是资料比较多,功能也更强大一些。后来同事推荐看下gitea,感觉它也还不错,而且比较轻量,使用gitea在家庭内网创建一个ci/cd环境,保存一些资料和代码,并部署应用。其实最初是准备上gitlab的,一个是资料比较多,功能也更强大一些。后来同事推荐看下gitea,感觉它也还不错,而且比较轻量,使用。

步骤:安装一个ubuntu server的虚拟机

在虚拟机里面安装docker

sudo apt-get remove docker docker-engine docker.io containerd runc

sudo apt-get update

sudo apt-get install -y \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \$(lsb_release -cs)\stable"

sudo apt-get update

sudo apt-get install -y docker-ce docker-ce-cli containerd.io

sudo apt install -y python3-pip

sudo pip3 install docker-compose

3. 根据官方提供的docker-composer模版创建自己的 docker-compose.yml

version:"3"networks:gitea:external:falseservices:server:image:gitea/gitea:latestcontainer_name:giteaenvironment:- USER_UID=1000- USER_GID=1000- DB_TYPE=postgres- DB_HOST=db:5432- DB_NAME=gitea- DB_USER=gitea- DB_PASSWD=gitearestart:alwaysnetworks:- giteavolumes:- /data/gitea:/data- /etc/timezone:/etc/timezone:ro- /etc/localtime:/etc/localtime:roports:- "3000:3000"- "222:22"depends_on:- dbdb:image:postgres:9.6restart:alwaysenvironment:- POSTGRES_USER=gitea- POSTGRES_PASSWORD=gitea- POSTGRES_DB=giteanetworks:- giteavolumes:- /data/postgres:/var/lib/postgresql/data

执行

docker-compose up -d

其实这个gitea镜像可以设置的环境变量有不少,下面粗字部分是默认值APP_NAME: “Gitea: Git with a cup of tea”: Application name, used in the page title.

RUN_MODE: dev: For performance and other purposes, change this to prod when deployed to a production environment.

DOMAIN: localhost: Domain name of this server, used for the displayed http clone URL in Gitea’s UI.

SSH_DOMAIN: localhost: Domain name of this server, used for the displayed ssh clone URL in Gitea’s UI. If the install page is enabled, SSH Domain Server takes DOMAIN value in the form (which overwrite this setting on save).

SSH_PORT: 22: SSH port displayed in clone URL.

SSH_LISTEN_PORT: %(SSH_PORT)s: Port for the built-in SSH server.

DISABLE_SSH: false: Disable SSH feature when it’s not available.

HTTP_PORT: 3000: HTTP listen port.

ROOT_URL: "": Overwrite the automatically generated public URL. This is useful if the internal and the external URL don’t match (e.g. in Docker).

LFS_START_SERVER: false: Enables git-lfs support.

DB_TYPE: sqlite3: The database type in use [mysql, postgres, mssql, sqlite3].

DB_HOST: localhost:3306: Database host address and port.

DB_NAME: gitea: Database name.

DB_USER: root: Database username.

DB_PASSWD: "”: Database user password. Use `your password` for quoting if you use special characters in the password.

INSTALL_LOCK: false: Disallow access to the install page.

SECRET_KEY: "": Global secret key. This should be changed. If this has a value and INSTALL_LOCK is empty, INSTALL_LOCK will automatically set to true.

DISABLE_REGISTRATION: false: Disable registration, after which only admin can create accounts for users.

REQUIRE_SIGNIN_VIEW: false: Enable this to force users to log in to view any page.

USER_UID: 1000: The UID (Unix user ID) of the user that runs Gitea within the container. Match this to the UID of the owner of the /data volume if using host volumes (this is not necessary with named volumes).

USER_GID: 1000: The GID (Unix group ID) of the user that runs Gitea within the container. Match this to the GID of the owner of the /data volume if using host volumes (this is not necessary with named volumes).

4. 浏览器登录 http://server-ip:3000 就可以看到 gitea的初始化页面了,然后是注册一个账号,剩下就和github操作差不多

5. 在初始化系统页面可以设置禁止自动注册

6. 可以创建Access Token ,用于pull或者pushGitea: Git with a cup of tea​try.gitea.io80c1e17a406700f1a31b0623cf47d00d.png文档 - Docs​docs.gitea.io110413e2d93d6f4941effb1cbbb62b3d.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值