在家庭内网创建一个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 teatry.gitea.io文档 - Docsdocs.gitea.io