[±] New article (chinese version)
This commit is contained in:
parent
3739fcbbd7
commit
4e03562460
@ -1,13 +1,13 @@
|
|||||||
---
|
---
|
||||||
title: Deploy Gitea using Podman on Linux
|
title: Deploy Gitea using Podman on Linux
|
||||||
date: 2025-01-03
|
date: 2025-01-03
|
||||||
categories: Tech
|
categories: [Tech, Self-Hosted]
|
||||||
---
|
---
|
||||||
|
|
||||||
Gitea is a lightweight, self-hosted DevOps platform with features such as Git hosting, code review, team collaboration, package registry, and CI/CD.
|
Gitea is a lightweight, self-hosted DevOps platform with features such as Git hosting, code review, team collaboration, package registry, and CI/CD.
|
||||||
To ensure that Gitea meets your needs, it is recommended to read the [comparison table](https://docs.gitea.com/installation/comparison) for Gitea and other competing products (e.g. GitLab CE) before installing it.
|
To ensure that Gitea meets your needs, it is recommended to read the [comparison table](https://docs.gitea.com/installation/comparison) for Gitea and other competing products (e.g. GitLab CE) before installing it.
|
||||||
|
|
||||||
### Install Podman [^1]
|
## Install Podman [^1]
|
||||||
|
|
||||||
Podman can be installed using package managers (recommended) or manually build from source.
|
Podman can be installed using package managers (recommended) or manually build from source.
|
||||||
|
|
||||||
@ -20,9 +20,9 @@ sudo pacman -S podman
|
|||||||
sudo apk add podman
|
sudo apk add podman
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are using RHEL, please read the appropriate [docs](https://access.redhat.com/solutions/3650231) in Red Hat Knowledgebase.
|
If you are using RHEL, please read the appropriate [docs](https://access.redhat.com/solutions/3650231) in the Red Hat Knowledgebase.
|
||||||
|
|
||||||
### Install Podman Compose [^2]
|
## Install Podman Compose [^2]
|
||||||
|
|
||||||
Podman itself does NOT support the [compose specification](https://compose-spec.io). To use features like Docker Compose with Podman, we need to install a community-maintained utility named Podman Compose.
|
Podman itself does NOT support the [compose specification](https://compose-spec.io). To use features like Docker Compose with Podman, we need to install a community-maintained utility named Podman Compose.
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ source .venv/bin/activate
|
|||||||
pip install podman-compose
|
pip install podman-compose
|
||||||
```
|
```
|
||||||
|
|
||||||
### Write Compose File [^3]
|
## Write Compose File [^3]
|
||||||
|
|
||||||
Podman Compose uses the same syntax as Docker Compose. So you can even just copy the docker-compose.yml from the official Gitea docs.
|
Podman Compose uses the same syntax as Docker Compose. So you can even just copy the docker-compose.yml from the official Gitea docs.
|
||||||
|
|
||||||
@ -85,13 +85,13 @@ podman-compose up -d
|
|||||||
|
|
||||||
Note: Gitea uses SQLite as the default database. If you want to use an external database (MySQL or PostgreSQL), please add the corresponding part after Gitea's compose configuration.
|
Note: Gitea uses SQLite as the default database. If you want to use an external database (MySQL or PostgreSQL), please add the corresponding part after Gitea's compose configuration.
|
||||||
|
|
||||||
### Configure Gitea
|
## Configure Gitea
|
||||||
|
|
||||||
After starting the container, you should visit `http://SERVER_IP:3000` and follow the installation wizard. The first user registered will become the admin.
|
After starting the container, you should visit `http://SERVER_IP:3000` and follow the installation wizard. The first user registered will become the admin.
|
||||||
|
|
||||||
Then, you can find the configuration file for Gitea at `CUSTOM_FOLDER/gitea/conf/app.ini`, which includes the settings you entered in the installation wizard.
|
Then, you can find the configuration file for Gitea at `CUSTOM_FOLDER/gitea/conf/app.ini`, which includes the settings you entered in the installation wizard.
|
||||||
|
|
||||||
#### Email Notification [^4]
|
### Email Notification [^4]
|
||||||
|
|
||||||
Gitea supports the following protocols: smtp, smtps, smtp+starttls, smtp+unix, sendmail, dummy. The most common protocol is smtps, so if you are not sure which one to use, use that one.
|
Gitea supports the following protocols: smtp, smtps, smtp+starttls, smtp+unix, sendmail, dummy. The most common protocol is smtps, so if you are not sure which one to use, use that one.
|
||||||
|
|
||||||
@ -110,11 +110,11 @@ USER =
|
|||||||
PASSWD =
|
PASSWD =
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Other Settings
|
### Other Settings
|
||||||
|
|
||||||
See the [Cheat Sheet](https://docs.gitea.com/administration/config-cheat-sheet) for explanations of more configuration items such as SSL, Git LFS, and Oauth.
|
See the [Cheat Sheet](https://docs.gitea.com/administration/config-cheat-sheet) for explanations of more configuration items such as SSL, Git LFS, and Oauth.
|
||||||
|
|
||||||
### End
|
## End
|
||||||
|
|
||||||
Now, enjoy your Gitea - git with a cup of tea!
|
Now, enjoy your Gitea - git with a cup of tea!
|
||||||
|
|
||||||
|
130
content/zh-cn/post/deploy-gitea-using-podman.md
Normal file
130
content/zh-cn/post/deploy-gitea-using-podman.md
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
---
|
||||||
|
title: 使用 Podman 在 Linux 上部署 Gitea
|
||||||
|
date: 2025-01-03
|
||||||
|
categories: [科技, 自托管]
|
||||||
|
---
|
||||||
|
|
||||||
|
**声明:如本文之中、英文版本有任何歧义,均以英文版为准。我们会尽力保证中文版的准确性。**
|
||||||
|
|
||||||
|
Gitea 是一个轻量级的自托管 DevOps 平台,提供 Git 托管、代码审查、团队协作、软件包注册和 CI/CD 等功能。
|
||||||
|
为确保 Gitea 满足您的需求,建议在安装前阅读 Gitea 与其他竞品(如 GitLab 社区版)的[对照表](https://docs.gitea.com/installation/comparison)。
|
||||||
|
|
||||||
|
## 安装 Podman [^1]
|
||||||
|
|
||||||
|
Podman 可以通过包管理器安装(推荐)或手动从源代码构建。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Debian & Ubuntu
|
||||||
|
sudo apt-get install podman
|
||||||
|
# Arch & Manjaro
|
||||||
|
sudo pacman -S podman
|
||||||
|
# Alpine
|
||||||
|
sudo apk add podman
|
||||||
|
```
|
||||||
|
|
||||||
|
如果您使用的是 RHEL,请参阅 Red Hat 知识库中对应的[文档](https://access.redhat.com/solutions/3650231)。
|
||||||
|
|
||||||
|
## 安装 Podman Compose [^2]
|
||||||
|
|
||||||
|
Podman 本体不支持 [Compose 规范](https://compose-spec.io)。要使用类似 Docker Compose 的功能,我们需要安装一个由社区维护的实用程序 Podman Compose。
|
||||||
|
|
||||||
|
另,Podman 原生支持 Kubernetes,您也可以使用 Kubernetes 的配置文件来运行 Gitea。
|
||||||
|
|
||||||
|
建议使用 pip(Python 的包管理器)安装 Podman Compose。
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
sudo apt-get install python3-pip -y
|
||||||
|
pip3 install podman-compose
|
||||||
|
```
|
||||||
|
|
||||||
|
如果遇到 *externally-managed-environment* 的错误,可以尝试以下两种解决方案。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 使用 pipx
|
||||||
|
sudo apt-get install pipx -y
|
||||||
|
sudo pipx ensurepath --global
|
||||||
|
pipx install podman-compose
|
||||||
|
|
||||||
|
# 创建虚拟环境
|
||||||
|
# 若使用此方法,您只能在当前文件夹中使用 podman-compose
|
||||||
|
python3 -m venv .venv
|
||||||
|
source .venv/bin/activate
|
||||||
|
pip install podman-compose
|
||||||
|
```
|
||||||
|
|
||||||
|
## 撰写 Compose 文件 [^3]
|
||||||
|
|
||||||
|
Podman Compose 使用与 Docker Compose 相同的语法。因此您甚至可以直接复制 Gitea 官方文档中的 docker-compose.yml 文件。
|
||||||
|
|
||||||
|
以下是我的 Compose 文件,供参考。
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
gitea:
|
||||||
|
image: docker.io/gitea/gitea:latest
|
||||||
|
container_name: gitea
|
||||||
|
restart: unless-stopped
|
||||||
|
network_mode: host
|
||||||
|
environment:
|
||||||
|
- USER_UID=1000
|
||||||
|
- USER_GID=1000
|
||||||
|
volumes:
|
||||||
|
- /usr/local/gitea/data:/data
|
||||||
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
```
|
||||||
|
|
||||||
|
使用上述配置需要执行以下命令。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 创建 Gitea 的目录
|
||||||
|
mkdir /usr/local/gitea /usr/local/gitea/data
|
||||||
|
# 允许容器对数据文件夹进行读写
|
||||||
|
chown 1000:1000 /usr/local/gitea/data
|
||||||
|
# 运行 podman compose
|
||||||
|
podman-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
注意:Gitea 默认使用 SQLite 数据库。如果需要使用外部数据库(MySQL 或 PostgreSQL),请在 Gitea 配置部分后添加相应的配置。
|
||||||
|
|
||||||
|
## 配置 Gitea
|
||||||
|
|
||||||
|
在启动容器后,您应该访问 `http://SERVER_IP:3000`,并按照安装向导进行操作。第一个注册的用户将成为站点管理员。
|
||||||
|
|
||||||
|
此后,您可以在 `CUSTOM_FOLDER/gitea/conf/app.ini` 中找到 Gitea 的配置文件,其中包含您之前在安装向导中输入的设置信息。
|
||||||
|
|
||||||
|
### 邮件通知 [^4]
|
||||||
|
|
||||||
|
Gitea 支持以下协议:smtp、smtps、smtp+starttls、smtp+unix、sendmail、dummy。最常用的是 smtps,如果不确定使用哪种协议,请选择 smtps。
|
||||||
|
|
||||||
|
FROM 属性的值应为类似`发件人名称 <电子邮件地址>`的格式,例如 `Gitea <git@example.com>`。您也可以直接输入电子邮件地址 `git@example.com`。
|
||||||
|
|
||||||
|
如果您的密码包含特殊字符,请在密码两侧加上单引号 (`'`)。
|
||||||
|
|
||||||
|
```
|
||||||
|
[mailer]
|
||||||
|
ENABLED = true
|
||||||
|
FROM =
|
||||||
|
PROTOCOL =
|
||||||
|
SMTP_ADDR =
|
||||||
|
SMTP_PORT =
|
||||||
|
USER =
|
||||||
|
PASSWD =
|
||||||
|
```
|
||||||
|
|
||||||
|
### 其他设置
|
||||||
|
|
||||||
|
请查阅[配置说明](https://docs.gitea.com/zh-cn/administration/config-cheat-sheet)以了解更多配置项的说明,例如 SSL、Git LFS 和 Oauth。
|
||||||
|
|
||||||
|
## 结语
|
||||||
|
|
||||||
|
现在,您可以使用您的 Gitea 实例了。
|
||||||
|
|
||||||
|
[^1]: Podman 官方文档
|
||||||
|
https://podman.io/docs/installation
|
||||||
|
[^2]: Podman Compose Github 仓库
|
||||||
|
https://github.com/containers/podman-compose
|
||||||
|
[^3]: Gitea 官方文档:*使用 Docker 安装*
|
||||||
|
https://docs.gitea.com/zh-cn/installation/install-with-docker
|
||||||
|
[^4]: Gitea 官方文档:*Email 设置*
|
||||||
|
https://docs.gitea.com/zh-cn/administration/email-setup
|
@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
title: 这里暂时什么都没有。
|
|
||||||
date: 2024-01-28
|
|
||||||
---
|
|
Loading…
Reference in New Issue
Block a user