feat: update gitea & gitea config

This commit is contained in:
Sun-ZhenXing
2026-07-22 15:44:52 +08:00
parent 3432c9da65
commit 87a58d8d04
15 changed files with 1162 additions and 928 deletions
+2 -2
View File
@@ -85,8 +85,8 @@ These services require building custom Docker images from source.
| [Flowise](./src/flowise) | 3.0.12 |
| [frpc](./src/frpc) | 0.68.1 |
| [frps](./src/frps) | 0.68.1 |
| [Gitea Runner](./src/gitea-runner) | 0.2.13 |
| [Gitea](./src/gitea) | 1.25.4-rootless |
| [Gitea Runner](./src/gitea-runner) | 2.1.0 |
| [Gitea](./src/gitea) | 1.27.0-rootless |
| [GitLab Runner](./src/gitlab-runner) | 17.10.1 |
| [GitLab](./src/gitlab) | 18.8.3-ce.0 |
| [GoModel](./src/gomodel) | v0.1.27 |
+2 -2
View File
@@ -85,8 +85,8 @@ docker compose exec redis redis-cli ping
| [Flowise](./src/flowise) | 3.0.12 |
| [frpc](./src/frpc) | 0.68.1 |
| [frps](./src/frps) | 0.68.1 |
| [Gitea Runner](./src/gitea-runner) | 0.2.13 |
| [Gitea](./src/gitea) | 1.25.4-rootless |
| [Gitea Runner](./src/gitea-runner) | 2.1.0 |
| [Gitea](./src/gitea) | 1.27.0-rootless |
| [GitLab Runner](./src/gitlab-runner) | 17.10.1 |
| [GitLab](./src/gitlab) | 18.8.3-ce.0 |
| [GoModel](./src/gomodel) | v0.1.27 |
+1 -1
View File
@@ -88,7 +88,7 @@ services:
- archon_postgres_data:/var/lib/postgresql/data
- ./migrations/000_combined.sql:/docker-entrypoint-initdb.d/000_combined.sql:ro
healthcheck:
test: [CMD-SHELL, 'pg_isready -U postgres -d remote_coding_agent']
test: [CMD-SHELL, pg_isready -U postgres -d remote_coding_agent]
interval: 10s
timeout: 5s
retries: 5
+2 -2
View File
@@ -17,7 +17,7 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@antfu/eslint-config": "^7.4.3",
"eslint": "^10.0.1"
"@antfu/eslint-config": "^9.2.0",
"eslint": "^10.7.0"
}
}
+836 -692
View File
File diff suppressed because it is too large Load Diff
+28 -10
View File
@@ -1,14 +1,32 @@
# Gitea Runner version
GITEA_RUNNER_VERSION=0.2.13
# Optional registry prefix. Include the trailing slash, for example registry.example.com/
GLOBAL_REGISTRY=
# Gitea instance URL
INSTANCE_URL=http://localhost:3000
# Gitea Runner image version.
GITEA_RUNNER_VERSION=2.1.0
# Registration token (get from Gitea settings -> Actions -> Runners)
REGISTRATION_TOKEN=
# Container time zone.
TZ=UTC
# Runner name
RUNNER_NAME=Gitea-Runner
# Gitea URL. It must be reachable from both the runner and job containers.
GITEA_INSTANCE_URL=http://host.docker.internal:3000
# Runner labels
RUNNER_LABELS=DockerRunner
# Required registration token from Gitea Settings -> Actions -> Runners.
GITEA_RUNNER_REGISTRATION_TOKEN=
# Name shown for this runner in Gitea.
GITEA_RUNNER_NAME=Gitea-Runner
# Comma-separated runner labels.
GITEA_RUNNER_LABELS=ubuntu-latest:docker://docker.io/gitea/runner-images:ubuntu-latest,ubuntu-24.04:docker://docker.io/gitea/runner-images:ubuntu-24.04,ubuntu-22.04:docker://docker.io/gitea/runner-images:ubuntu-22.04
# Maximum CPU allocation.
GITEA_RUNNER_CPU_LIMIT=1.0
# Maximum memory allocation.
GITEA_RUNNER_MEMORY_LIMIT=2G
# Reserved CPU allocation.
GITEA_RUNNER_CPU_RESERVATION=0.1
# Reserved memory allocation.
GITEA_RUNNER_MEMORY_RESERVATION=1G
+48 -44
View File
@@ -2,56 +2,60 @@
[English](./README.md) | [中文](./README.zh.md)
This service sets up a Gitea Runner.
## Prerequisites
1. Generate the `config.yaml` file:
```bash
docker run --entrypoint="" --rm -it gitea/act_runner:0.2.13 act_runner generate-config > config.yaml
```
2. Configure `config.yaml`, for example:
```yaml
cache:
enabled: true
dir: ''
host: 192.168.8.17
port: 8088
```
3. Configure environment variables:
```properties
INSTANCE_URL=http://xxx:3000
REGISTRATION_TOKEN=xxxxxx
RUNNER_NAME=runner-1
RUNNER_LABELS=xxxxxx
```
## Start the Runner
```bash
docker compose up -d
```
This stack runs Gitea Runner 2.1.0 for Gitea Actions. The Compose service is `gitea_runner`; it executes jobs in Docker containers through the host Docker daemon.
## Services
- `runner`: The Gitea Runner service.
- `gitea_runner`: Registers with Gitea and creates Docker containers for Actions jobs.
## Prerequisite
Create a runner registration token in Gitea under **Settings -> Actions -> Runners**. The token is required.
## Quick Start
```bash
cp .env.example .env
# Set GITEA_RUNNER_REGISTRATION_TOKEN in .env and, when needed, GITEA_INSTANCE_URL.
docker compose up -d
```
The default `http://host.docker.internal:3000` targets a Gitea server published on port 3000 of the Docker host. Compose maps that hostname to the host gateway for the runner, and `config.yaml` does the same for job containers. Change the URL for a remote Gitea server, another port, or a deployment not reachable through the host; the selected URL must be reachable from both the runner and job containers.
## Configuration
### Environment Variables
| Variable | Default | Description |
| --------------------------------------------------------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| `GLOBAL_REGISTRY` | empty | Optional registry prefix, including its trailing `/`. |
| `GITEA_RUNNER_VERSION` | `2.1.0` | Runner image version. |
| `TZ` | `UTC` | Container time zone. |
| `GITEA_INSTANCE_URL` | `http://host.docker.internal:3000` | Gitea URL reachable by the runner and jobs. |
| `GITEA_RUNNER_REGISTRATION_TOKEN` | empty | Required registration token. |
| `GITEA_RUNNER_NAME` | `Gitea-Runner` | Runner name shown in Gitea. |
| `GITEA_RUNNER_LABELS` | `ubuntu-latest`, `ubuntu-24.04`, `ubuntu-22.04` Docker labels | Comma-separated labels using job images from `docker.io/gitea/runner-images`. |
| `GITEA_RUNNER_CPU_LIMIT` / `GITEA_RUNNER_CPU_RESERVATION` | `1.0` / `0.1` | CPU limit and reservation. |
| `GITEA_RUNNER_MEMORY_LIMIT` / `GITEA_RUNNER_MEMORY_RESERVATION` | `2G` / `1G` | Memory limit and reservation. |
- `INSTANCE_URL`: The URL of the Gitea instance.
- `REGISTRATION_TOKEN`: The registration token for the Gitea Runner.
- `RUNNER_NAME`: The name of the runner.
- `RUNNER_LABELS`: The labels for the runner.
The repository includes a ready-to-use `config.yaml`. To inspect a fresh upstream 2.1.0 configuration instead, run:
## Volumes
```bash
docker run --entrypoint="" --rm gitea/runner:2.1.0 gitea-runner generate-config > config.yaml
```
- `config.yaml`: The configuration file for the Gitea Runner.
- `data`: A volume for storing runner data.
- `/var/run/docker.sock`: For communicating with the Docker daemon.
## Storage and Health
- `gitea_runner_data` stores registration and runner state.
- `./config.yaml` is mounted read-only at `/config.yaml`.
- `/var/run/docker.sock` lets the runner create job containers.
- The healthcheck queries the internal metrics endpoint at `http://127.0.0.1:9101/healthz`.
## Security
Docker socket access is effectively host-level privilege. Do not run untrusted workflows on this runner. For stronger isolation, use a dedicated host or VM, or evaluate a rootless Docker-in-Docker setup.
## Migrating from act_runner
- The image and binary changed from `gitea/act_runner` and `act_runner` to `gitea/runner` and `gitea-runner`.
- Rename `INSTANCE_URL`, `REGISTRATION_TOKEN`, `RUNNER_NAME`, and `RUNNER_LABELS` to the corresponding official `GITEA_*` variables above.
- The default labels now include Ubuntu 24.04 and 22.04 images, and `container.force_pull` now defaults to `false`.
- Runner v2.0 introduced a breaking change for private-image credentials; review and reconfigure those credentials before running private images.
+48 -44
View File
@@ -2,56 +2,60 @@
[English](./README.md) | [中文](./README.zh.md)
服务用于搭建一个 Gitea Runner。
## 前提条件
1. 生成 `config.yaml` 文件:
```bash
docker run --entrypoint="" --rm -it gitea/act_runner:0.2.13 act_runner generate-config > config.yaml
```
2. 配置 `config.yaml`,例如:
```yaml
cache:
enabled: true
dir: ''
host: 192.168.8.17
port: 8088
```
3. 配置环境变量:
```properties
INSTANCE_URL=http://xxx:3000
REGISTRATION_TOKEN=xxxxxx
RUNNER_NAME=runner-1
RUNNER_LABELS=xxxxxx
```
## 启动 Runner
```bash
docker compose up -d
```
配置使用 Gitea Runner 2.1.0 运行 Gitea Actions。Compose 服务名为 `gitea_runner`,它通过宿主机的 Docker 守护进程在 Docker 容器中执行任务
## 服务
- `runner`: Gitea Runner 服务
- `gitea_runner`:注册到 Gitea,并为 Actions 任务创建 Docker 容器
## 前提条件
在 Gitea 的“设置 -> Actions -> Runners”中创建 Runner 注册令牌。此令牌为必填项。
## 快速开始
```bash
cp .env.example .env
# 在 .env 中设置 GITEA_RUNNER_REGISTRATION_TOKEN,并在需要时修改 GITEA_INSTANCE_URL。
docker compose up -d
```
默认地址 `http://host.docker.internal:3000` 指向 Docker 宿主机上发布到 3000 端口的 Gitea。Compose 会为 Runner 将该主机名映射到宿主机网关,`config.yaml` 也会为任务容器添加同一映射。如果 Gitea 位于远程主机、使用其他端口,或无法通过宿主机访问,请修改此地址;所选地址必须同时可被 Runner 和任务容器访问。
## 配置
### 环境变量
| 变量 | 默认值 | 说明 |
| --------------------------------------------------------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `GLOBAL_REGISTRY` | 空 | 可选镜像仓库前缀,必须包含末尾的 `/`。 |
| `GITEA_RUNNER_VERSION` | `2.1.0` | Runner 镜像版本。 |
| `TZ` | `UTC` | 容器时区。 |
| `GITEA_INSTANCE_URL` | `http://host.docker.internal:3000` | Runner 和任务容器均可访问的 Gitea 地址。 |
| `GITEA_RUNNER_REGISTRATION_TOKEN` | 空 | 必填的注册令牌。 |
| `GITEA_RUNNER_NAME` | `Gitea-Runner` | Gitea 中显示的 Runner 名称。 |
| `GITEA_RUNNER_LABELS` | `ubuntu-latest``ubuntu-24.04``ubuntu-22.04` Docker labels | 以逗号分隔的 labels,默认 job image repository 为 `docker.io/gitea/runner-images`。 |
| `GITEA_RUNNER_CPU_LIMIT` / `GITEA_RUNNER_CPU_RESERVATION` | `1.0` / `0.1` | CPU 限制和预留。 |
| `GITEA_RUNNER_MEMORY_LIMIT` / `GITEA_RUNNER_MEMORY_RESERVATION` | `2G` / `1G` | 内存限制和预留。 |
- `INSTANCE_URL`: Gitea 实例的 URL。
- `REGISTRATION_TOKEN`: Gitea Runner 的注册令牌。
- `RUNNER_NAME`: Runner 的名称。
- `RUNNER_LABELS`: Runner 的标签。
仓库已经提供可直接使用的 `config.yaml`,无需在启动前生成。如需查看上游 2.1.0 的新配置,可运行:
## 卷
```bash
docker run --entrypoint="" --rm gitea/runner:2.1.0 gitea-runner generate-config > config.yaml
```
- `config.yaml`: Gitea Runner 的配置文件。
- `data`: 用于存储 Runner 数据的卷。
- `/var/run/docker.sock`: 用于与 Docker守护进程通信
## 存储与健康检查
- `gitea_runner_data` 保存注册信息和 Runner 状态
- `./config.yaml` 以只读方式挂载到 `/config.yaml`
- `/var/run/docker.sock` 让 Runner 能够创建任务容器。
- 健康检查访问内部指标端点 `http://127.0.0.1:9101/healthz`
## 安全
访问 Docker 套接字等同于拥有宿主机级别的高权限。不要在此 Runner 上运行不可信 workflow。如需更强隔离,请使用专用宿主机或 VM,或评估 rootless Docker-in-Docker 方案。
## 从 act_runner 迁移
- 镜像和二进制名称已从 `gitea/act_runner``act_runner` 改为 `gitea/runner``gitea-runner`
- 将 `INSTANCE_URL``REGISTRATION_TOKEN``RUNNER_NAME``RUNNER_LABELS` 改为上表对应的官方 `GITEA_*` 变量。
- 默认 labels 现在包含 Ubuntu 24.04 和 22.04 镜像,`container.force_pull` 的默认值改为 `false`
- Runner v2.0 对私有镜像凭据引入了 breaking change;运行私有镜像前,请检查并重新配置相关凭据。
+78 -75
View File
@@ -1,110 +1,113 @@
# Example configuration file, it's safe to copy this as the default config file without any modification.
# You don't have to copy this file to your instance,
# just run `./act_runner generate-config > config.yaml` to generate a config file.
# Ready-to-use configuration for Gitea Runner 2.1.0.
log:
# The level of logging, can be trace, debug, info, warn, error, fatal
# Logging level: trace, debug, info, warn, error, or fatal.
level: info
runner:
# Where to store the registration result.
# Registration state file.
file: .runner
# Execute how many tasks concurrently at the same time.
# Maximum number of concurrent tasks.
capacity: 1
# Extra environment variables to run jobs.
envs:
A_TEST_ENV_NAME_1: a_test_env_value_1
A_TEST_ENV_NAME_2: a_test_env_value_2
# Extra environment variables to run jobs from a file.
# It will be ignored if it's empty or the file doesn't exist.
# Extra environment variables passed to jobs.
envs: {}
# Optional file containing extra job environment variables.
env_file: .env
# The timeout for a job to be finished.
# Please note that the Gitea instance also has a timeout (3h by default) for the job.
# So the job could be stopped by the Gitea instance if it's timeout is shorter than this.
# Maximum job runtime.
timeout: 3h
# The timeout for the runner to wait for running jobs to finish when shutting down.
# Any running jobs that haven't finished after this timeout will be cancelled.
# Time to wait for running jobs during shutdown; 0s waits indefinitely.
shutdown_timeout: 0s
# Whether skip verifying the TLS certificate of the Gitea instance.
# Skip TLS certificate verification for the Gitea instance.
insecure: false
# The timeout for fetching the job from the Gitea instance.
# Long-poll timeout when fetching jobs.
fetch_timeout: 5s
# The interval for fetching the job from the Gitea instance.
# Initial interval between job fetches.
fetch_interval: 2s
# The github_mirror of a runner is used to specify the mirror address of the github that pulls the action repository.
# It works when something like `uses: actions/checkout@v4` is used and DEFAULT_ACTIONS_URL is set to github,
# and github_mirror is not empty. In this case,
# it replaces https://github.com with the value here, which is useful for some special network environments.
# Maximum interval between job fetches while idle.
fetch_interval_max: 5s
# Remove working directories older than this age.
workdir_cleanup_age: 24h
# Interval for cleaning up idle working directories.
idle_cleanup_interval: 10m
# Interval for reporting job logs.
log_report_interval: 5s
# Maximum latency before pending logs are reported.
log_report_max_latency: 3s
# Maximum number of log lines sent in one batch.
log_report_batch_size: 100
# Interval for reporting job state.
state_report_interval: 5s
# Timeout for closing job reports.
report_close_timeout: 10s
# Optional GitHub mirror used for action repositories.
github_mirror: ''
# The labels of a runner are used to determine which jobs the runner can run, and how to run them.
# Like: "macos-arm64:host" or "ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest"
# Find more images provided by Gitea at https://gitea.com/docker.gitea.com/runner-images .
# If it's empty when registering, it will ask for inputting labels.
# If it's empty when execute `daemon`, will use labels in `.runner` file.
# Use shallow clones for action repositories.
action_shallow_clone: true
# Set act compatibility environment variables in jobs.
set_act_env: true
# Allocate a pseudo-TTY for jobs.
allocate_pty: false
# Optional shell script run after each task.
post_task_script: ''
# Maximum runtime for the post-task script.
post_task_script_timeout: 5m
# Labels determine which jobs this runner accepts and their execution images.
labels:
- 'ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest'
- 'ubuntu-22.04:docker://docker.gitea.com/runner-images:ubuntu-22.04'
- 'ubuntu-20.04:docker://docker.gitea.com/runner-images:ubuntu-20.04'
- 'ubuntu-latest:docker://docker.io/gitea/runner-images:ubuntu-latest'
- 'ubuntu-24.04:docker://docker.io/gitea/runner-images:ubuntu-24.04'
- 'ubuntu-22.04:docker://docker.io/gitea/runner-images:ubuntu-22.04'
cache:
# Enable cache server to use actions/cache.
# Enable the actions/cache-compatible cache server.
enabled: true
# The directory to store the cache data.
# If it's empty, the cache data will be stored in $HOME/.cache/actcache.
# Cache directory; empty uses the runner default.
dir: ''
# The host of the cache server.
# It's not for the address to listen, but the address to connect from job containers.
# So 0.0.0.0 is a bad choice, leave it empty to detect automatically.
# Address job containers use to reach the cache server; empty enables detection.
host: ''
# The port of the cache server.
# 0 means to use a random available port.
# Cache server port; 0 selects an available port.
port: 0
# The external cache server URL. Valid only when enable is true.
# If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself.
# The URL should generally end with "/".
# Optional external cache server URL.
external_server: ''
# Optional secret for the external cache server.
external_secret: ''
# Disable cache network access.
offline_mode: false
container:
# Specifies the network to which the container will connect.
# Could be host, bridge or the name of a custom network.
# If it's empty, act_runner will create a network automatically.
# Existing Docker network to use; empty creates a network per job.
network: ''
# Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker).
# Options applied when the runner creates a job network.
network_create_options:
enable_ipv4: true
enable_ipv6: false
# Run job containers in privileged mode.
privileged: false
# And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway).
options:
# The parent directory of a job's working directory.
# NOTE: There is no need to add the first '/' of the path as act_runner will add it automatically.
# If the path starts with '/', the '/' will be trimmed.
# For example, if the parent directory is /path/to/my/dir, workdir_parent should be path/to/my/dir
# If it's empty, /workspace will be used.
# Make the host-published Gitea URL resolvable from job containers.
options: >-
--add-host=host.docker.internal:host-gateway
# Parent directory for job workspaces; empty uses /workspace.
workdir_parent:
# Volumes (including bind mounts) can be mounted to containers. Glob syntax is supported, see https://github.com/gobwas/glob
# You can specify multiple volumes. If the sequence is empty, no volumes can be mounted.
# For example, if you only allow containers to mount the `data` volume and all the json files in `/src`, you should change the config to:
# valid_volumes:
# - data
# - /src/*.json
# If you want to allow any volume, please use the following configuration:
# valid_volumes:
# - '**'
# Bind the runner workspace directly into job containers.
bind_workdir: false
# Allowed job volume mounts.
valid_volumes: []
# overrides the docker client host with the specified one.
# If it's empty, act_runner will find an available docker host automatically.
# If it's "-", act_runner will find an available docker host automatically, but the docker host won't be mounted to the job containers and service containers.
# If it's not empty or "-", the specified docker host will be used. An error will be returned if it doesn't work.
# Docker daemon endpoint; empty enables automatic detection.
docker_host: ''
# Pull docker image(s) even if already present
force_pull: true
# Rebuild docker image(s) even if already present
# Pull images only when they are not already available.
force_pull: false
# Rebuild job images even when already available.
force_rebuild: false
# Always require a reachable docker daemon, even if not required by act_runner
# Require Docker even for jobs that otherwise do not need it.
require_docker: false
# Timeout to wait for the docker daemon to be reachable, if docker is required by require_docker or act_runner
# Time to wait for Docker; 0s uses the runner default.
docker_timeout: 0s
host:
# The parent directory of a job's working directory.
# If it's empty, $HOME/.cache/act/ will be used.
# Parent directory for host-mode job workspaces; empty uses the runner default.
workdir_parent:
metrics:
# Enabled so the Compose healthcheck can query /healthz.
enabled: true
# Metrics and health endpoint listen address.
addr: '127.0.0.1:9101'
+13 -5
View File
@@ -9,18 +9,26 @@ x-defaults: &defaults
services:
gitea_runner:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}gitea/act_runner:${GITEA_RUNNER_VERSION:-0.2.13}
image: ${GLOBAL_REGISTRY:-}gitea/runner:${GITEA_RUNNER_VERSION:-2.1.0}
environment:
TZ: ${TZ:-UTC}
CONFIG_FILE: /config.yaml
GITEA_INSTANCE_URL: ${INSTANCE_URL:-http://localhost:3000}
GITEA_RUNNER_REGISTRATION_TOKEN: ${REGISTRATION_TOKEN}
GITEA_RUNNER_NAME: ${RUNNER_NAME:-Gitea-Runner}
GITEA_RUNNER_LABELS: ${RUNNER_LABELS:-DockerRunner}
GITEA_INSTANCE_URL: ${GITEA_INSTANCE_URL:-http://host.docker.internal:3000}
GITEA_RUNNER_REGISTRATION_TOKEN: ${GITEA_RUNNER_REGISTRATION_TOKEN}
GITEA_RUNNER_NAME: ${GITEA_RUNNER_NAME:-Gitea-Runner}
GITEA_RUNNER_LABELS: ${GITEA_RUNNER_LABELS:-ubuntu-latest:docker://docker.io/gitea/runner-images:ubuntu-latest,ubuntu-24.04:docker://docker.io/gitea/runner-images:ubuntu-24.04,ubuntu-22.04:docker://docker.io/gitea/runner-images:ubuntu-22.04}
extra_hosts:
- host.docker.internal:host-gateway
volumes:
- ./config.yaml:/config.yaml:ro
- gitea_runner_data:/data
- /var/run/docker.sock:/var/run/docker.sock
healthcheck:
test: [CMD-SHELL, '/bin/busybox wget -q -O /dev/null http://127.0.0.1:9101/healthz || exit 1']
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
deploy:
resources:
limits:
+1 -1
View File
@@ -1,5 +1,5 @@
# Gitea Version
GITEA_VERSION=1.25.4-rootless
GITEA_VERSION=1.27.0-rootless
# Database configuration
GITEA_DB_TYPE=postgres
+49 -22
View File
@@ -2,42 +2,69 @@
[English](./README.md) | [中文](./README.zh.md)
This service sets up a Gitea service.
This stack runs Gitea 1.27.0 with the rootless image and PostgreSQL 17.6.
## Services
- `server`: The Gitea application service.
- `db`: The PostgreSQL database service.
- `gitea`: Gitea web and SSH service.
- `db`: PostgreSQL database service.
## Quick Start
Copying the example environment file is optional. Before the first startup, strongly consider changing `POSTGRES_PASSWORD`; the default is only suitable for local evaluation.
```bash
cp .env.example .env
# Edit POSTGRES_PASSWORD in .env.
docker compose up -d
```
Open <http://localhost:3000> after the services become healthy.
## Initial Setup
On the initial setup page, you need to fill in the database information:
Use these database settings on the Gitea installation page:
- Database Type: `PostgreSQL`
- Database type: `PostgreSQL`
- Host: `db:5432`
- User: `gitea`
- Password: `gitea` (default)
- Database Name: `gitea`
- User: `gitea`, or the value of `POSTGRES_USER`
- Database name: `gitea`, or the value of `POSTGRES_DB`
- Password: the value of `POSTGRES_PASSWORD`
The first registered user will have administrator privileges.
The first registered user becomes an administrator.
## Configuration
You can configure the basic information of Gitea through the `./config/app.ini` file. For example, you can disable the registration function with the following configuration:
| Variable | Default | Description |
| --- | --- | --- |
| `GITEA_VERSION` | `1.27.0-rootless` | Gitea image tag. |
| `GITEA_DB_TYPE` | `postgres` | Gitea database type. |
| `GITEA_POSTGRES_HOST` | `db:5432` | PostgreSQL address inside the Compose network. |
| `POSTGRES_VERSION` | `17.6` | PostgreSQL image version. |
| `POSTGRES_USER` | `gitea` | Database user. |
| `POSTGRES_PASSWORD` | `gitea` | Database password; change it for production. |
| `POSTGRES_DB` | `gitea` | Database name. |
| `GITEA_HTTP_PORT` | `3000` | Published Gitea HTTP port. |
| `GITEA_SSH_PORT` | `2222` | Published Gitea SSH port. |
```ini
[service]
DISABLE_REGISTRATION = true
```
### Default Ports
### Environment Variables
| Service | Host port | Container port |
| --- | --- | --- |
| Gitea HTTP | `3000` | `3000` |
| Gitea SSH | `2222` | `2222` |
| PostgreSQL | Not published | `5432` |
- `POSTGRES_USER`: The username for the PostgreSQL database, default is `gitea`.
- `POSTGRES_PASSWORD`: The password for the PostgreSQL database, default is `gitea`.
- `POSTGRES_DB`: The name of the PostgreSQL database, default is `gitea`.
## Storage
## Volumes
- `gitea_data`: Gitea repositories and application data.
- `gitea_config`: Gitea configuration.
- `postgres`: PostgreSQL database files.
- `data`: A volume for storing Gitea data.
- `config`: A volume for storing Gitea configuration.
- `postgres`: A volume for storing PostgreSQL data.
## Upgrading
Before upgrading from an older release, back up the `postgres`, `gitea_data`, and `gitea_config` volumes. Gitea automatically runs database migrations during startup; do not downgrade directly after a migration. Restore a compatible backup instead.
## Security
The Gitea application uses the rootless image. The default database password is only for local evaluation and must be changed in production. Publish the HTTP and SSH ports only when needed, and restrict their network exposure with host firewall or proxy rules.
+48 -21
View File
@@ -2,42 +2,69 @@
[English](./README.md) | [中文](./README.zh.md)
服务用于搭建一个 Gitea 服务
配置使用 rootless 镜像运行 Gitea 1.27.0,并使用 PostgreSQL 17.6 作为数据库
## 服务
- `server`: Gitea 应用服务。
- `db`: PostgreSQL 数据库服务。
- `gitea`Gitea Web 与 SSH 服务。
- `db`PostgreSQL 数据库服务。
## 快速开始
复制环境变量示例文件是可选步骤。强烈建议在首次启动前修改 `POSTGRES_PASSWORD`;默认密码仅适合本地评估。
```bash
cp .env.example .env
# 在 .env 中修改 POSTGRES_PASSWORD。
docker compose up -d
```
服务健康后,访问 <http://localhost:3000>。
## 初始设置
初始页面需要填入数据库信息
Gitea 安装页面中使用以下数据库设置
- 数据库类型:`PostgreSQL`
- 主机:`db:5432`
- 用户`gitea`
- 密码`gitea`(默认值)
- 数据库名称:`gitea`
- 用户:`gitea`,或 `POSTGRES_USER` 的值
- 数据库名称`gitea`,或 `POSTGRES_DB` 的值
- 密码:`POSTGRES_PASSWORD` 的值
第一个注册的用户将拥有管理员权限
第一个注册的用户将成为管理员。
## 配置
可以通过 `./config/app.ini` 文件配置 Gitea 的基本信息。例如,通过以下配置可以关闭注册功能:
| 变量 | 默认值 | 说明 |
| --- | --- | --- |
| `GITEA_VERSION` | `1.27.0-rootless` | Gitea 镜像标签。 |
| `GITEA_DB_TYPE` | `postgres` | Gitea 数据库类型。 |
| `GITEA_POSTGRES_HOST` | `db:5432` | Compose 网络内的 PostgreSQL 地址。 |
| `POSTGRES_VERSION` | `17.6` | PostgreSQL 镜像版本。 |
| `POSTGRES_USER` | `gitea` | 数据库用户。 |
| `POSTGRES_PASSWORD` | `gitea` | 数据库密码,生产环境必须修改。 |
| `POSTGRES_DB` | `gitea` | 数据库名称。 |
| `GITEA_HTTP_PORT` | `3000` | Gitea HTTP 发布端口。 |
| `GITEA_SSH_PORT` | `2222` | Gitea SSH 发布端口。 |
```ini
[service]
DISABLE_REGISTRATION = true
```
### 默认端口
### 环境变量
| 服务 | 宿主机端口 | 容器端口 |
| --- | --- | --- |
| Gitea HTTP | `3000` | `3000` |
| Gitea SSH | `2222` | `2222` |
| PostgreSQL | 不发布 | `5432` |
- `POSTGRES_USER`: PostgreSQL 数据库的用户名,默认为 `gitea`
- `POSTGRES_PASSWORD`: PostgreSQL 数据库的密码,默认为 `gitea`
- `POSTGRES_DB`: PostgreSQL 数据库的名称,默认为 `gitea`
## 存储
## 卷
- `gitea_data`:保存 Gitea 仓库和应用数据。
- `gitea_config`:保存 Gitea 配置。
- `postgres`:保存 PostgreSQL 数据库文件。
- `data`: 用于存储 Gitea 数据的卷。
- `config`: 用于存储 Gitea 配置的卷。
- `postgres`: 用于存储 PostgreSQL 数据的卷
## 升级
从旧版本升级前,请备份 `postgres``gitea_data``gitea_config` volumes。Gitea 会在启动时自动执行数据库 migration;执行 migration 后不要直接降级,应恢复兼容版本的备份
## 安全
Gitea 应用使用 rootless 镜像。默认数据库密码仅适合本地评估,生产环境必须修改。仅按需发布 HTTP 和 SSH 端口,并通过宿主机防火墙或代理规则限制网络访问。
+1 -1
View File
@@ -9,7 +9,7 @@ x-defaults: &defaults
services:
gitea:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}gitea/gitea:${GITEA_VERSION:-1.25.4-rootless}
image: ${GLOBAL_REGISTRY:-}gitea/gitea:${GITEA_VERSION:-1.27.0-rootless}
environment:
- USER_UID=1000
- USER_GID=1000
+5 -6
View File
@@ -32,12 +32,11 @@ services:
- no-new-privileges:true
healthcheck:
test:
[
CMD,
sh,
-ec,
"curl -fsS http://127.0.0.1:9000/health && curl -fsS http://127.0.0.1:9001/rustfs/console/health",
]
- CMD
- sh
- -ec
- 'curl -fsS http://127.0.0.1:9000/health && curl -fsS http://127.0.0.1:9001/rustfs/console/health'
interval: 30s
timeout: 10s
retries: 3