An easy-to-build code hosting platform Gitea

insert image description here

SSDIt's a bit moldy this week. First, it hangs up on the machine for daily use, and it can't be recognized at all.

Two days later, on the small machine used to write articles, 500Gthe mechanical hard disk also hung up, and I re-formatted it, and hung it 玩客云up as a download disk.

insert image description here

Fortunately, there are backups, but the restoration Dockerof is a bit troublesome, such as:

  • HomeAssistant, using the previously exported syno.txzand re- imported, the configuration file has not been moved, but there are still various problems;
  • messense/aliyundrive-webdavIf latestthe version , Hyper Backupit will be displayed in the log when backing up HTTP status client error (400 Bad Request) for url (https://openapi.aliyundrive.com/adrive/v1.0/openFile/get_by_path);
  • vaultwarden/serverIf you use latestthe version , you will always report an error when you log in Username or Password is incorrect. Try again., and it will be displayed in the log (login) POST /identity/connect/token => 400 Bad Request;

vpsThis week, Tencent’s cloudflare tunnel.


The software in this article 不长到一百四誓不改名is recommended ; but Lao Su does not know how to use it, and his level will git cloneonly use it;

What is Gitea?

GiteaThe primary goal of the service is to create a self-built Gitservice . We use Goas the back-end language, which allows us to only generate an executable program. And he also supports cross-platform, supports Linux, macOSand Windowsand various architectures, in addition x86to amd64, also includes ARMand PowerPC.

If you don't want to build it yourself, you can go online demo: https://try.gitea.io

Install

build database

Lao Su used MariaDB 10the database .

phpMyAdminCreate an empty database named in gitea.

For illustration purposes, assume the database password is123456

insert image description here

Therefore, according to the above settings, the final database-related parameters are as follows:

  • Database host: 192.168.0.197, IPconsistent ;
  • Database port: 3307, if you use MariaDB 5it 3306, but Lao Su didn’t test it;
  • Database user:gitea
  • Database password:123456
  • Database name: gitea, because the same name as the user is selected;

install mirror

Install it in Docker mode on Synology.

If you are familiar with the command line, it may be docker clifaster

When Lao Su is tossing, latestthe corresponding version is1.19.3

# 新建文件夹 gitea 和 子目录
mkdir -p /volume2/docker/gitea/data

# 进入 gitea 目录
cd /volume2/docker/gitea

# 运行容器
docker run -d \
   --restart always \
   --name gitea \
   -p 3231:3000 \
   -p 222:22 \
   -v $(pwd)/data:/data \
   -v /etc/TZ:/etc/TZ:ro \
   -v /etc/localtime:/etc/localtime:ro \
   -e USER_UID=1000 \
   -e USER_GID=1000 \
   -e GITEA__database__DB_TYPE=mysql \
   -e GITEA__database__HOST=192.168.0.197:3307 \
   -e GITEA__database__NAME=gitea \
   -e GITEA__database__USER=gitea \
   -e GITEA__database__PASSWD=123456 \
   gitea/gitea:latest
variable value
USER_UID Giteaof the user running inside the container UID, defaults to1000
USER_GID Giteaof the user running inside the container GID, defaults to1000
GITEA__database__DB_TYPE database type
GITEA__database__HOST database host
GITEA__database__NAME database name
GITEA__database__USER database user
GITEA__database__PASSWD database password

For more environment variables, please see the official documentation: https://docs.gitea.cn/installation/install-with-docker#environment variables

You can also use docker-composethe installation , save the following content as docker-compose.ymla file

version: "3"

services:
  server:
    image: gitea/gitea:latest
    container_name: gitea
    restart: always
    volumes:
      - ./data:/data
      - /etc/TZ:/etc/TZ:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3231:3000"
      - "222:22"
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=mysql
      - GITEA__database__HOST=192.168.0.197:3307  
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=123456

Then execute the following command

# 新建文件夹 gitea 和 子目录
mkdir -p /volume2/docker/gitea/data

# 进入 gitea 目录
cd /volume2/docker/gitea

# 将 docker-compose.yml 放入当前目录

# 一键启动
docker-compose up -d

run

Enter in the browser http://群晖IP:3231, the first time you need to configure

Lao Su didn’t change anything, including mail settings and administrators, I’ll talk about it later

insert image description here

There is a short loading process

insert image description here

Followed by the login interface

insert image description here

Because there is no administrator set at the beginning, the first registered user is the administrator

insert image description here

The main interface after successful creation

insert image description here

set up

insert image description here

Management background

Supports migration from other repositories

configuration file

GiteaThe configuration file is saved in /data/gitea/conf/app.ini, FileStationin , the corresponding path is/docker/gitea/data/gitea/conf/app.ini

insert image description here

Before app.inimaking any changes to , you need to add Everyoneread and write permissions for

insert image description here

Otherwise the modification will be invalid

After modifying the settings, you need to restart the container for the settings to take effect

disable registration

If you want to disable registration, then only administrators can create accounts for users. Although troublesome, it may be safer

One way is through environment variables DISABLE_REGISTRATION=true, the other is in ,app.ini change fromDISABLE_REGISTRATIONfalsetrue

insert image description here

After restarting the container, it can no longer be registered

E-Mail settings

Because we didn't set the email when we initialized at the beginning, so now app.iniit looks like this

[mailer]
ENABLED = false

If you want to configure the mail service, you must first ENABLEDchange to true, and add the following content at the same time. Of course, the settings are different for different mailboxes, which is why Lao Su did not set it at the beginning

[mailer]
ENABLED         = true
FROM            = [email protected]
MAILER_TYPE     = smtp
HOST            = smtp.88.com:465
IS_TLS_ENABLED  = true
USER            = [email protected]
PASSWD          = <第三方邮件客户端>

When creating a user, if email notification is checked

insert image description here

will receive the mail soon

insert image description here

client

GiteaThe server uses SSHthe protocol , and SSHthe port is not the default. 22Instead 222, Lao Su searched, and there are two methods:

The following content has not been verified by Lao Su, please check it yourself;

  • The first way Gitis to specify the port number in the remote repository address of the , for example:git remote add origin ssh://user@host:port/path/to/repo

  • The second is to modify the local configuration file. You Windowscan configureC:\Users\<YourUserName>\.ssh\config the port number in the file under , for example:SSH

Host gitserver
    HostName gitserver.com
    Port 222
    User git

You can then use git remote add origin git@gitserver:path/to/repoto add remote repositories.

reference documents

Gitea
address: https://gitea.io/en-us/

gitea/README_ZH.md at main go-gitea/gitea GitHub
address: https://github.com/go-gitea/gitea/blob/main/README_ZH.md

Documentation | Gitea Official Documentation
Address: https://docs.gitea.cn/

Install with Docker - Docs
address: https://docs.gitea.io/en-us/install-with-docker/

Guess you like

Origin blog.csdn.net/wbsu2004/article/details/131280270