重构为 musl 纯静态打包,配置迁 /etc,对齐三项目
Build and Release / release (push) Has been skipped
Build and Release / build-and-test (amd64) (push) Failing after 3m8s
Build and Release / build-and-test (arm64) (push) Failing after 7m31s

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 14:55:12 +08:00
co-authored by Claude Opus 4.8
parent b222b802bf
commit 3b024fdc10
14 changed files with 307 additions and 312 deletions
+64 -75
View File
@@ -1,102 +1,91 @@
# P2Pool Docker 构建基础设施
# P2Pool
[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)]()
[![License](https://img.shields.io/badge/license-MIT-blue.svg)]()
P2Pool 是 [SChernykh/p2pool](https://github.com/SChernykh/p2pool) 的定制打包——Monero 去中心化矿池的 sidechain 节点。对上游唯一定制是**禁用合并挖矿捐赠**(`-DWITH_MERGE_MINING_DONATION=OFF`),不改源码。
为 [p2pool](https://github.com/SChernykh/p2pool) 提供的自动化 Docker 构建和打包系统
**本仓库只包含构建与打包基础设施**,不含 p2pool 源码:二进制在 CI 中从上游官方仓库 `github.com/SChernykh/p2pool` 编译,再打包分发到 [gitea.bcde.io](https://gitea.bcde.io) 的 Generic / Debian 包仓库
## 📋 项目简介
## 产物
这是一个专业的构建基础设施项目,用于自动化构建、打包和分发 p2pool(Monero 去中心化矿池)的多架构二进制文件和 Debian 软件包。
每次构建产出单个可执行文件(musl 纯静态,自带 boringssl/libuv/libzmq,无外部动态库依赖,任意 Linux 发行版可跑):
**关键特性**
- 🏗️ 多架构支持(amd64、arm64
- 📦 多发行版构建(Alpine、Ubuntu
- 🤖 全自动 CI/CD 流程
- 🔒 禁用合并挖矿捐赠
- 📊 原生架构构建(无 QEMU
| 二进制 | 作用 |
|---|---|
| `p2pool` | P2Pool sidechain 节点:连接 monerod、维护 sidechain、向矿工提供 stratum |
## 🚀 快速开始
支持架构 `amd64` / `arm64`musl 纯静态,任意 Linux 发行版(Debian/Ubuntu/Alpine/CentOS 等)开箱即跑。静态构建仍保留 `--rpc-ssl`,可连接外部 SSL monerod 节点。
### Debian/Ubuntu(推荐)
## 安装
### APTDebian / Ubuntu
```bash
# 下载 GPG 密钥
sudo curl https://gitea.bcde.io/api/packages/wangdefa/debian/repository.key -o /etc/apt/keyrings/gitea-wangdefa.asc
# 添加仓库
echo "deb [signed-by=/etc/apt/keyrings/gitea-wangdefa.asc] https://gitea.bcde.io/api/packages/wangdefa/debian stable main" | sudo tee -a /etc/apt/sources.list.d/wangdefa.list
# 更新并安装
sudo apt-get update
sudo apt-get install p2pool
echo "deb [signed-by=/etc/apt/keyrings/gitea-wangdefa.asc] https://gitea.bcde.io/api/packages/wangdefa/debian stable main" | sudo tee /etc/apt/sources.list.d/wangdefa.list
sudo apt-get update && sudo apt-get install p2pool
```
修改配置:
安装布局:
| | 路径 |
|---|---|
| 二进制 | `/opt/p2pool/p2pool` |
| 默认配置 | `/opt/p2pool/params.conf`postinst 复制到 `/etc/p2pool/params.conf` |
| 数据 | `/var/lib/p2pool/data-api` |
| 日志 | `/var/log/p2pool/` |
| 服务 | `p2pool.service` |
> 安装后服务**不会自动启动**(须先填钱包地址)。编辑 `/etc/p2pool/params.conf` 设置 Monero 钱包地址,再启用:
>
> ```bash
> sudo systemctl enable --now p2pool
> ```
### tar.gz(通用:Alpine / Ubuntu / Debian
从 Generic Package Registry 下载对应架构的 tar.gz,解压即用(单二进制):
```bash
# 设置你的 Monero 钱包地址
sudo nano /var/lib/p2pool/params.conf
# 启动服务
sudo systemctl enable --now p2pool.service
curl -fSL -o p2pool.tar.gz \
https://gitea.bcde.io/api/packages/wangdefa/generic/p2pool/4.15.1/p2pool-amd64-linux-static-4.15.1.tar.gz
tar -xzf p2pool.tar.gz
./p2pool --params-file params.conf # 配置模板见仓库 conf/params.conf.example
```
### 本地构建
## 构建与发布
CI 定义于 [.gitea/workflows/ci.yaml](.gitea/workflows/ci.yaml)
- **push 到 `main`/`develop`**:矩阵 `arch=[amd64,arm64]`,在原生 runner 上用 Dockermusl 纯静态)编译为 tar.gz 并打 `.deb`
- **打 tag**:产物上传到 Generic / Debian 包仓库并创建 Release。
本地构建:
```bash
# Alpine 构建(推荐,体积更小
docker buildx build --pull \
--platform linux/amd64 \
# 编译某架构二进制(输出到 ./output/linux_<arch>/p2pool
docker buildx build --platform linux/amd64 \
--build-arg P2POOL_VERSION=v4.15.1 \
--output type=local,dest=./output \
-f docker/Dockerfile.alpine .
-f docker/Dockerfile .
# Ubuntu 构建
docker buildx build --pull \
--platform linux/amd64 \
--build-arg P2POOL_VERSION=v4.15.1 \
--output type=local,dest=./output \
-f docker/Dockerfile.ubuntu .
# 校验纯静态(应输出 "not a dynamic executable"
ldd output/linux_amd64/p2pool
# 用产物 tar.gz 打 .deb
./debian/build-deb.sh amd64 4.15.1 p2pool-amd64-linux-static-4.15.1.tar.gz
```
## 🏗️ 构建系统
## 版本号约定
### 支持的架构和平台
- **上游源码 git tag** 带 `v`(如 `v4.15.1`),CI 用 `P2POOL_VERSION=v${PACKAGE_VERSION}` 检出。
- **包版本**tar.gz / deb / registry 路径)一律用数字(如 `4.15.1`),符合 Debian 版本规范。
| 架构 | Alpine | Ubuntu | Debian 包 |
|------|--------|--------|-----------|
| amd64 | ✅ | ✅ | ✅ |
| arm64 | ✅ | ✅ | ✅ |
发版只需改 ci.yaml 的 `PACKAGE_VERSION`
### 构建产物
## 目录结构
- **二进制包** (`tar.gz`) - 适用于所有 Linux 发行版
- **Debian 包** (`.deb`) - 适用于 Debian/Ubuntu 系统
## 🔧 配置管理
配置文件模板:[params.conf.example](params.conf.example)
## 🔐 安全性
- ✅ 禁用上游合并挖矿捐赠
- ✅ 使用专用用户运行服务
- ✅ Systemd 安全加固
- ✅ 最小权限原则
- ✅ 安全的文件权限设置
## 📄 许可证
本项目为上游 [p2pool](https://github.com/SChernykh/p2pool) 提供构建基础设施。
上游项目许可证:GPL-3.0
## 🔗 相关链接
- **上游项目**: [SChernykh/p2pool](https://github.com/SChernykh/p2pool)
- **Monero**: [getmonero.org](https://www.getmonero.org/)
---
**注意**: 本仓库不包含 p2pool 源代码,仅提供构建和打包基础设施。
```
.gitea/workflows/ CI 流水线
docker/ Dockerfile(musl 纯静态,从上游官方源码编译)
debian/ .deb 打包:control 模板、维护脚本、systemd 服务
conf/ params.conf.example 默认配置模板
```