添加配置文件管理和完整文档系统
All checks were successful
Build and Release / build-and-test (arm64, alpine) (push) Successful in 30s
Build and Release / build-and-test (amd64, alpine) (push) Successful in 42s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 41s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 54s
Build and Release / release (push) Has been skipped
All checks were successful
Build and Release / build-and-test (arm64, alpine) (push) Successful in 30s
Build and Release / build-and-test (amd64, alpine) (push) Successful in 42s
Build and Release / build-and-test (arm64, ubuntu) (push) Successful in 41s
Build and Release / build-and-test (amd64, ubuntu) (push) Successful in 54s
Build and Release / release (push) Has been skipped
- 重构配置方式:使用 params.conf 替代命令行参数 - postinst 自动创建配置文件,升级时保护用户配置 - 初始化 llmdoc 文档系统(概述、架构、指南、参考) - 创建 README.md 和配置指南 - 提供完整的配置模板示例 配置文件优势:升级安全、集中管理、易于维护
This commit is contained in:
113
README-params.md
Normal file
113
README-params.md
Normal file
@@ -0,0 +1,113 @@
|
||||
# P2Pool Configuration File Guide
|
||||
|
||||
## Overview
|
||||
|
||||
P2Pool uses a configuration file (`params.conf`) to manage all runtime settings. This approach provides several advantages over command-line parameters:
|
||||
|
||||
- **Upgrade Safety**: Configuration is preserved during package upgrades
|
||||
- **Centralized Management**: All settings in one location
|
||||
- **Documentation**: In-file comments explain each option
|
||||
- **Maintainability**: Easy to review and modify settings
|
||||
|
||||
## Configuration File Locations
|
||||
|
||||
### Debian Package Installation
|
||||
```
|
||||
/var/lib/p2pool/params.conf
|
||||
```
|
||||
|
||||
### Manual Installation
|
||||
```
|
||||
./params.conf (in the working directory)
|
||||
```
|
||||
|
||||
## Basic Configuration Example
|
||||
|
||||
```conf
|
||||
# Minimum required configuration
|
||||
host = 127.0.0.1
|
||||
rpc-port = 18081
|
||||
zmq-port = 18083
|
||||
wallet = 4xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
```
|
||||
|
||||
## Advanced Configuration
|
||||
|
||||
See [params.conf.example](params.conf.example) for a comprehensive configuration template with all available options.
|
||||
|
||||
## Configuration Best Practices
|
||||
|
||||
1. **Always backup** your `params.conf` before making changes
|
||||
2. **Test changes** by running P2Pool manually before updating the systemd service
|
||||
3. **Use comments** to document your customizations
|
||||
4. **Keep sensitive data secure**: The config file contains your wallet address
|
||||
|
||||
## Switching from Command-Line to Configuration File
|
||||
|
||||
If you're currently using command-line parameters, you can convert them to a configuration file:
|
||||
|
||||
```bash
|
||||
# Old way (command-line)
|
||||
p2pool --host 127.0.0.1 --rpc-port 18081 --wallet YOUR_WALLET
|
||||
|
||||
# New way (configuration file)
|
||||
p2pool --params-file params.conf
|
||||
```
|
||||
|
||||
## Testing Your Configuration
|
||||
|
||||
```bash
|
||||
# Test configuration before starting the service
|
||||
sudo -u p2pool /opt/p2pool/p2pool --params-file /var/lib/p2pool/params.conf
|
||||
|
||||
# If everything looks good, start the service
|
||||
sudo systemctl start p2pool.service
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Configuration Not Loading
|
||||
|
||||
1. Check file permissions:
|
||||
```bash
|
||||
ls -l /var/lib/p2pool/params.conf
|
||||
# Should be readable by p2pool user
|
||||
```
|
||||
|
||||
2. Verify file syntax:
|
||||
```bash
|
||||
# No equal signs in comments
|
||||
# Use "key = value" format
|
||||
# One setting per line
|
||||
```
|
||||
|
||||
3. Check systemd service logs:
|
||||
```bash
|
||||
sudo journalctl -u p2pool -n 50
|
||||
```
|
||||
|
||||
### Common Mistakes
|
||||
|
||||
- ❌ Missing wallet address
|
||||
- ❌ Incorrect Monero node connection settings
|
||||
- ❌ Syntax errors (missing `=`, extra spaces)
|
||||
- ❌ Commented-out required settings
|
||||
|
||||
## Migration from Older Versions
|
||||
|
||||
If you're upgrading from a version that used systemd service file configuration:
|
||||
|
||||
1. Copy your settings from the old service file
|
||||
2. Convert them to `params.conf` format
|
||||
3. Update the service file to use `--params-file`
|
||||
4. Restart the service
|
||||
|
||||
Example migration:
|
||||
```bash
|
||||
# Old (in systemd service)
|
||||
ExecStart=/opt/p2pool/p2pool --host 127.0.0.1 --wallet XXXXX
|
||||
|
||||
# New (in params.conf)
|
||||
host = 127.0.0.1
|
||||
wallet = XXXXX
|
||||
```
|
||||
184
README.md
Normal file
184
README.md
Normal file
@@ -0,0 +1,184 @@
|
||||
# P2Pool Docker 构建基础设施
|
||||
|
||||
[]()
|
||||
[]()
|
||||
|
||||
为 [p2pool](https://github.com/SChernykh/p2pool) 提供的自动化 Docker 构建和打包系统。
|
||||
|
||||
## 📋 项目简介
|
||||
|
||||
这是一个专业的构建基础设施项目,用于自动化构建、打包和分发 p2pool(Monero 去中心化矿池)的多架构二进制文件和 Debian 软件包。
|
||||
|
||||
**关键特性**:
|
||||
- 🏗️ 多架构支持(amd64、arm64)
|
||||
- 📦 多发行版构建(Alpine、Ubuntu)
|
||||
- 🤖 全自动 CI/CD 流程
|
||||
- 🔒 禁用合并挖矿捐赠
|
||||
- 📊 原生架构构建(无 QEMU)
|
||||
|
||||
## 🚀 快速开始
|
||||
|
||||
### 使用 Debian 包安装(推荐)
|
||||
|
||||
```bash
|
||||
# 1. 添加包仓库
|
||||
sudo curl https://GITEA_URL/api/packages/OWNER/debian/repository.key \
|
||||
-o /etc/apt/keyrings/gitea-OWNER.asc
|
||||
|
||||
echo "deb [signed-by=/etc/apt/keyrings/gitea-OWNER.asc] \
|
||||
https://GITEA_URL/api/packages/OWNER/debian bookworm main" | \
|
||||
sudo tee /etc/apt/sources.list.d/OWNER.list
|
||||
|
||||
# 2. 安装 P2Pool
|
||||
sudo apt-get update
|
||||
sudo apt-get install p2pool
|
||||
|
||||
# 3. 配置
|
||||
sudo nano /var/lib/p2pool/params.conf
|
||||
# 设置你的 Monero 钱包地址
|
||||
|
||||
# 4. 启动服务
|
||||
sudo systemctl enable --now p2pool.service
|
||||
```
|
||||
|
||||
详细配置说明请查看:[README-params.md](README-params.md)
|
||||
|
||||
### 本地构建
|
||||
|
||||
```bash
|
||||
# Alpine 构建(推荐,体积更小)
|
||||
docker buildx build --pull \
|
||||
--platform linux/amd64 \
|
||||
--build-arg P2POOL_VERSION=v4.13 \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile.alpine .
|
||||
|
||||
# Ubuntu 构建
|
||||
docker buildx build --pull \
|
||||
--platform linux/amd64 \
|
||||
--build-arg P2POOL_VERSION=v4.13 \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile.ubuntu .
|
||||
```
|
||||
|
||||
## 📚 文档
|
||||
|
||||
完整的项目文档位于 [llmdoc/](llmdoc/) 目录:
|
||||
|
||||
- **[项目概述](llmdoc/overview/project-overview.md)** - 了解项目目的和架构
|
||||
- **[CI/CD 架构](llmdoc/architecture/cicd-architecture.md)** - 自动化构建流程
|
||||
- **[Docker 架构](llmdoc/architecture/docker-architecture.md)** - 多阶段构建系统
|
||||
- **[本地构建指南](llmdoc/guides/local-build.md)** - 开发者构建指南
|
||||
- **[Debian 包指南](llmdoc/guides/debian-package.md)** - 安装和配置
|
||||
|
||||
## 🏗️ 构建系统
|
||||
|
||||
### 支持的架构和平台
|
||||
|
||||
| 架构 | Alpine | Ubuntu | Debian 包 |
|
||||
|------|--------|--------|-----------|
|
||||
| amd64 | ✅ | ✅ | ✅ |
|
||||
| arm64 | ✅ | ✅ | ✅ |
|
||||
|
||||
### 构建产物
|
||||
|
||||
- **二进制包** (`tar.gz`) - 适用于所有 Linux 发行版
|
||||
- **Debian 包** (`.deb`) - 适用于 Debian/Ubuntu 系统
|
||||
- **多发行版支持** - Debian 12 (bookworm)、Debian 13 (trixie)
|
||||
|
||||
## 🔧 配置管理
|
||||
|
||||
本项目使用配置文件管理 P2Pool 设置,提供以下优势:
|
||||
|
||||
- ✅ **升级安全** - 配置文件在包升级时不会被覆盖
|
||||
- ✅ **集中管理** - 所有设置在一个位置
|
||||
- ✅ **易于维护** - 支持注释和版本控制
|
||||
|
||||
配置文件模板:[params.conf.example](params.conf.example)
|
||||
|
||||
## 📦 发布流程
|
||||
|
||||
项目使用 Gitea Actions 实现自动化 CI/CD:
|
||||
|
||||
1. **代码推送** → 触发构建(main/develop 分支)
|
||||
2. **创建标签** → 触发完整发布流程
|
||||
3. **自动构建** → 4 种组合(2 架构 × 2 发行版)
|
||||
4. **自动发布** → 上传到包注册中心
|
||||
5. **创建 Release** → 附带下载链接和说明
|
||||
|
||||
## 🛠️ 技术栈
|
||||
|
||||
- **构建工具**: Docker, Docker Buildx
|
||||
- **编译工具**: CMake, GCC, G++
|
||||
- **依赖库**: libuv, libzmq, libcurl
|
||||
- **CI/CD**: Gitea Actions
|
||||
- **包管理**: dpkg, apt
|
||||
|
||||
## 📖 开发指南
|
||||
|
||||
### 更新 p2pool 版本
|
||||
|
||||
```bash
|
||||
# 1. 编辑 CI 配置
|
||||
vim .gitea/workflows/ci.yaml
|
||||
# 更新 PACKAGE_VERSION 变量
|
||||
|
||||
# 2. 本地测试构建
|
||||
docker buildx build \
|
||||
--build-arg P2POOL_VERSION=vX.Y.Z \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile.alpine .
|
||||
|
||||
# 3. 创建版本标签
|
||||
git tag vX.Y.Z
|
||||
git push origin vX.Y.Z
|
||||
```
|
||||
|
||||
### 编码规范
|
||||
|
||||
项目遵循以下规范:
|
||||
|
||||
- **Shell 脚本**: 使用 `set -e`,严格参数验证
|
||||
- **Dockerfile**: 多阶段构建,优化缓存利用
|
||||
- **CI/CD**: 使用构建矩阵,原生架构运行器
|
||||
|
||||
详见:[编码规范](llmdoc/reference/coding-conventions.md) | [Git 规范](llmdoc/reference/git-conventions.md)
|
||||
|
||||
## 🔐 安全性
|
||||
|
||||
- ✅ 禁用上游合并挖矿捐赠
|
||||
- ✅ 使用专用用户运行服务
|
||||
- ✅ Systemd 安全加固
|
||||
- ✅ 最小权限原则
|
||||
- ✅ 安全的文件权限设置
|
||||
|
||||
## 🤝 贡献
|
||||
|
||||
欢迎提交 Issue 和 Pull Request!
|
||||
|
||||
在提交 PR 前,请确保:
|
||||
1. 代码符合项目编码规范
|
||||
2. 更新相关文档
|
||||
3. 测试所有受影响的构建配置
|
||||
|
||||
## 📄 许可证
|
||||
|
||||
本项目为上游 [p2pool](https://github.com/SChernykh/p2pool) 提供构建基础设施。
|
||||
|
||||
上游项目许可证:GPL-3.0
|
||||
|
||||
## 🔗 相关链接
|
||||
|
||||
- **上游项目**: [SChernykh/p2pool](https://github.com/SChernykh/p2pool)
|
||||
- **Monero**: [getmonero.org](https://www.getmonero.org/)
|
||||
- **项目文档**: [llmdoc/index.md](llmdoc/index.md)
|
||||
|
||||
## 💬 支持
|
||||
|
||||
- 📖 查看 [文档](llmdoc/index.md)
|
||||
- 🐛 提交 [Issue](../../issues)
|
||||
- 💡 参考 [配置指南](README-params.md)
|
||||
|
||||
---
|
||||
|
||||
**注意**: 本仓库不包含 p2pool 源代码,仅提供构建和打包基础设施。
|
||||
12
debian/p2pool.service
vendored
12
debian/p2pool.service
vendored
@@ -8,17 +8,7 @@ Type=simple
|
||||
User=p2pool
|
||||
Group=p2pool
|
||||
WorkingDirectory=/var/lib/p2pool
|
||||
ExecStart=/opt/p2pool/p2pool \
|
||||
--host 127.0.0.1 \
|
||||
--rpc-port 18081 \
|
||||
--zmq-port 18083 \
|
||||
--wallet YOUR_MONERO_WALLET_ADDRESS \
|
||||
--merge-mine tari://TARI_NODE_IP:18102 TARI_WALLET_ADDRESS \
|
||||
--p2p 0.0.0.0:37889 \
|
||||
--data-api /var/lib/p2pool/data-api \
|
||||
--local-api \
|
||||
--log-file /var/log/p2pool/p2pool.log \
|
||||
--loglevel 3
|
||||
ExecStart=/opt/p2pool/p2pool --params-file /var/lib/p2pool/params.conf
|
||||
Restart=on-failure
|
||||
RestartSec=10s
|
||||
StandardOutput=journal
|
||||
|
||||
57
debian/postinst
vendored
57
debian/postinst
vendored
@@ -17,6 +17,44 @@ mkdir -p /var/lib/p2pool
|
||||
chown p2pool:p2pool /var/lib/p2pool
|
||||
chmod 750 /var/lib/p2pool
|
||||
|
||||
# Create example params.conf if it doesn't exist
|
||||
if [ ! -f /var/lib/p2pool/params.conf ]; then
|
||||
cat > /var/lib/p2pool/params.conf << 'EOF'
|
||||
# P2Pool Configuration File
|
||||
# Edit this file with your settings and restart the service
|
||||
|
||||
# Monero node connection
|
||||
host = 127.0.0.1
|
||||
rpc-port = 18081
|
||||
zmq-port = 18083
|
||||
|
||||
# Your Monero wallet address (REQUIRED)
|
||||
wallet = YOUR_MONERO_WALLET_ADDRESS
|
||||
|
||||
# P2P settings
|
||||
p2p = 0.0.0.0:37889
|
||||
|
||||
# API settings
|
||||
data-api = /var/lib/p2pool/data-api
|
||||
local-api = true
|
||||
|
||||
# Logging
|
||||
log-file = /var/log/p2pool/p2pool.log
|
||||
loglevel = 3
|
||||
|
||||
# Mining mode (uncomment to enable mini sidechain)
|
||||
# mini = true
|
||||
|
||||
# Merge mining (optional - uncomment to enable Tari merge mining)
|
||||
# merge-mine = tari://TARI_NODE_IP:18102 TARI_WALLET_ADDRESS
|
||||
|
||||
# Stratum server (for miners to connect)
|
||||
# stratum = 0.0.0.0:3333
|
||||
EOF
|
||||
chown p2pool:p2pool /var/lib/p2pool/params.conf
|
||||
chmod 640 /var/lib/p2pool/params.conf
|
||||
fi
|
||||
|
||||
# Create log directory
|
||||
mkdir -p /var/log/p2pool
|
||||
chown p2pool:p2pool /var/log/p2pool
|
||||
@@ -34,13 +72,12 @@ fi
|
||||
echo ""
|
||||
echo "✅ P2Pool installed successfully!"
|
||||
echo ""
|
||||
echo "📋 Before starting P2Pool, you MUST:"
|
||||
echo "📋 Before starting P2Pool, you MUST configure your settings:"
|
||||
echo ""
|
||||
echo "1. Edit the systemd service file to set your Monero wallet address:"
|
||||
echo " sudo systemctl edit --full p2pool.service"
|
||||
echo "1. Edit the configuration file:"
|
||||
echo " sudo nano /var/lib/p2pool/params.conf"
|
||||
echo ""
|
||||
echo " Replace 'YOUR_MONERO_WALLET_ADDRESS' with your actual Monero wallet address"
|
||||
echo " and configure --host and --rpc-port to point to your Monero node"
|
||||
echo " Set your Monero wallet address and adjust other settings as needed."
|
||||
echo ""
|
||||
echo "2. Start P2Pool:"
|
||||
echo " sudo systemctl enable p2pool.service"
|
||||
@@ -50,9 +87,13 @@ echo "3. Check status:"
|
||||
echo " sudo systemctl status p2pool.service"
|
||||
echo " sudo journalctl -u p2pool -f"
|
||||
echo ""
|
||||
echo "Data directory: /var/lib/p2pool"
|
||||
echo "Log directory: /var/log/p2pool"
|
||||
echo "Binary: /opt/p2pool/p2pool"
|
||||
echo "📁 Important paths:"
|
||||
echo " Config file: /var/lib/p2pool/params.conf"
|
||||
echo " Data directory: /var/lib/p2pool"
|
||||
echo " Log directory: /var/log/p2pool"
|
||||
echo " Binary: /opt/p2pool/p2pool"
|
||||
echo ""
|
||||
echo "💡 Tip: Your params.conf will NOT be overwritten during package upgrades."
|
||||
echo ""
|
||||
echo "For help:"
|
||||
echo " /opt/p2pool/p2pool --help"
|
||||
|
||||
83
llmdoc/architecture/cicd-architecture.md
Normal file
83
llmdoc/architecture/cicd-architecture.md
Normal file
@@ -0,0 +1,83 @@
|
||||
# CI/CD 架构
|
||||
|
||||
## 流水线概述
|
||||
|
||||
P2Pool 构建系统使用 Gitea Actions 实现自动化构建、测试和发布流程。
|
||||
|
||||
## 构建矩阵
|
||||
|
||||
### 架构支持
|
||||
- amd64
|
||||
- arm64
|
||||
|
||||
### 发行版本
|
||||
- Ubuntu
|
||||
- Alpine Linux
|
||||
|
||||
### 构建组合
|
||||
- 总计 4 种构建变体:
|
||||
1. amd64 + Ubuntu
|
||||
2. amd64 + Alpine
|
||||
3. arm64 + Ubuntu
|
||||
4. arm64 + Alpine
|
||||
|
||||
## 流水线触发条件
|
||||
|
||||
### 自动触发
|
||||
- 推送到 `main` 和 `develop` 分支
|
||||
- 创建 Git 标签(发布版本)
|
||||
|
||||
## 流水线阶段
|
||||
|
||||
### 构建与测试阶段
|
||||
```yaml
|
||||
jobs:
|
||||
build-and-test:
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [amd64, arm64]
|
||||
distro: [ubuntu, alpine]
|
||||
|
||||
# 使用原生架构的 runner
|
||||
runs-on: >-
|
||||
${{
|
||||
matrix.arch == 'amd64' && 'ubuntu-latest-amd64' ||
|
||||
'ubuntu-latest-arm64'
|
||||
}}
|
||||
```
|
||||
|
||||
### 关键步骤
|
||||
1. 设置 Docker Buildx
|
||||
2. 构建二进制文件
|
||||
3. 打包为 tar.gz
|
||||
4. 对于 Ubuntu:创建 Debian 包
|
||||
5. 上传构建产物
|
||||
|
||||
### 发布阶段
|
||||
- 下载所有构建产物
|
||||
- 上传到 Gitea 通用包仓库
|
||||
- 上传 Debian 包
|
||||
- 创建发布版本
|
||||
- 附加下载链接
|
||||
|
||||
## 性能特点
|
||||
|
||||
### 原生架构构建
|
||||
- 比 QEMU 跨架构编译快 3-10 倍
|
||||
- 构建稳定性高
|
||||
- 需要专用的 amd64 和 arm64 runner
|
||||
|
||||
### 编译并行度
|
||||
- amd64:使用一半 CPU 核心
|
||||
- arm64:使用全部 CPU 核心
|
||||
- 跨架构编译:限制为 2 个并行作业
|
||||
|
||||
## 关键配置文件
|
||||
|
||||
- [.gitea/workflows/ci.yaml](../../.gitea/workflows/ci.yaml):主要 CI/CD 配置
|
||||
|
||||
## 安全与性能平衡
|
||||
|
||||
- 限制并行编译作业数
|
||||
- 使用原生架构 runner
|
||||
- 避免使用 QEMU 虚拟化
|
||||
58
llmdoc/architecture/debian-packaging.md
Normal file
58
llmdoc/architecture/debian-packaging.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Debian 包配置管理架构
|
||||
|
||||
## 1. 配置文件管理机制
|
||||
|
||||
### 配置文件位置和格式
|
||||
- **文件路径:** `/var/lib/p2pool/params.conf`
|
||||
- **文件权限:** `640` (所有者: `p2pool:p2pool`)
|
||||
- **格式:** 基于命令行参数的 key-value 配置文件
|
||||
|
||||
### 配置文件生命周期
|
||||
|
||||
#### 创建时机
|
||||
- **首次安装:** `postinst` 脚本自动创建示例配置文件
|
||||
- **升级场景:** 现有配置文件被完全保留,不会被覆盖
|
||||
|
||||
#### 配置文件生成策略
|
||||
```bash
|
||||
# 配置文件初始化伪代码
|
||||
if [ ! -f /var/lib/p2pool/params.conf ]; then
|
||||
cp /usr/share/p2pool/params.conf.example /var/lib/p2pool/params.conf
|
||||
chown p2pool:p2pool /var/lib/p2pool/params.conf
|
||||
chmod 640 /var/lib/p2pool/params.conf
|
||||
fi
|
||||
```
|
||||
|
||||
### 配置加载机制
|
||||
- systemd 服务使用 `--params-file /var/lib/p2pool/params.conf` 加载配置
|
||||
- 配置文件支持所有原命令行参数
|
||||
- 配置文件优先级高于硬编码的默认值
|
||||
|
||||
## 2. 安全与管理特性
|
||||
|
||||
### 权限控制
|
||||
- 仅 `p2pool` 系统用户可读写配置文件
|
||||
- 组权限限制,防止非授权访问敏感配置
|
||||
- 文件权限 `640` 确保最小权限原则
|
||||
|
||||
### 升级保护
|
||||
- 配置文件在包升级过程中保持不变
|
||||
- 新版本兼容旧配置文件格式
|
||||
- 升级后可通过比较 `params.conf.example` 检查新增配置项
|
||||
|
||||
## 3. 配置示例
|
||||
|
||||
```conf
|
||||
# /var/lib/p2pool/params.conf 示例
|
||||
wallet=YOUR_MONERO_WALLET_ADDRESS
|
||||
host=0.0.0.0
|
||||
rpc-port=3333
|
||||
log-level=1
|
||||
```
|
||||
|
||||
## 4. 设计考量
|
||||
|
||||
### 动机
|
||||
- 简化复杂的命令行参数管理
|
||||
- 提供更好的配置持久化方案
|
||||
- 增强系统配置的可读性和可维护性
|
||||
93
llmdoc/architecture/docker-architecture.md
Normal file
93
llmdoc/architecture/docker-architecture.md
Normal file
@@ -0,0 +1,93 @@
|
||||
# Docker 构建架构
|
||||
|
||||
## 多阶段构建策略
|
||||
|
||||
P2Pool 的 Docker 构建使用多阶段构建,确保最终镜像轻量且安全。
|
||||
|
||||
### 构建阶段概览
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────┐
|
||||
│ 阶段 1:基础镜像 (Alpine 3.21 / Ubuntu 24.04) │
|
||||
│ - 安装构建依赖: │
|
||||
│ git, cmake, gcc, g++, make │
|
||||
│ libuv-dev, libzmq-dev, libcurl-dev │
|
||||
└─────────────────┬───────────────────────────────┘
|
||||
│
|
||||
┌─────────────────▼───────────────────────────────┐
|
||||
│ 阶段 2:构建 │
|
||||
│ 1. 从 GitHub 克隆 p2pool(使用 --recursive) │
|
||||
│ 2. 检出指定的 P2POOL_VERSION 标签 │
|
||||
│ 3. CMake 配置: │
|
||||
│ - 发布构建 │
|
||||
│ - 禁用合并挖矿捐赠 │
|
||||
│ 4. 使用 make 编译: │
|
||||
│ - 交叉编译:-j2 │
|
||||
│ - amd64:-j$(nproc / 2) │
|
||||
│ - arm64:-j$(nproc) │
|
||||
└─────────────────┬───────────────────────────────┘
|
||||
│
|
||||
┌─────────────────▼───────────────────────────────┐
|
||||
│ 阶段 3:提取 (scratch 镜像) │
|
||||
│ - 将二进制文件复制到 /linux_${TARGETARCH}/ │
|
||||
│ - 启用 Docker buildx 本地文件提取 │
|
||||
└──────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
## 关键构建参数
|
||||
|
||||
### 版本控制
|
||||
- `P2POOL_VERSION`:指定上游 p2pool 版本
|
||||
- 使用 `--build-arg` 传递版本
|
||||
|
||||
### 编译配置
|
||||
- `-DWITH_MERGE_MINING_DONATION=OFF`:禁用合并挖矿捐赠
|
||||
- 不同架构的编译并行度控制
|
||||
|
||||
## 镜像变体
|
||||
|
||||
### Alpine 镜像 (推荐)
|
||||
- 基于 Alpine Linux
|
||||
- 镜像体积小
|
||||
- 安全性高
|
||||
- 文件:`docker/Dockerfile.alpine`
|
||||
|
||||
### Ubuntu 镜像
|
||||
- 基于 Ubuntu LTS
|
||||
- 更广泛的系统兼容性
|
||||
- 文件:`docker/Dockerfile.ubuntu`
|
||||
|
||||
## 构建命令示例
|
||||
|
||||
```bash
|
||||
# Alpine 构建(推荐)
|
||||
docker buildx build --pull \
|
||||
--platform linux/amd64 \
|
||||
--build-arg P2POOL_VERSION=v4.9.1 \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile.alpine .
|
||||
|
||||
# 多架构构建
|
||||
docker buildx build --pull \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--build-arg P2POOL_VERSION=v4.9.1 \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile.alpine .
|
||||
```
|
||||
|
||||
## 性能优化策略
|
||||
|
||||
### 并行度控制
|
||||
- amd64:`$(nproc) / 2`(减少资源竞争)
|
||||
- arm64:`$(nproc)`(充分利用资源)
|
||||
|
||||
### 缓存优化
|
||||
- 使用多阶段构建减少最终镜像大小
|
||||
- 利用 Docker 构建缓存
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 需要 Docker Buildx 支持
|
||||
- 构建需要互联网连接
|
||||
- 克隆上游仓库需要 `--recursive` 参数
|
||||
- 编译过程禁用合并挖矿捐赠功能
|
||||
135
llmdoc/guides/debian-package.md
Normal file
135
llmdoc/guides/debian-package.md
Normal file
@@ -0,0 +1,135 @@
|
||||
# Debian 包安装与配置指南
|
||||
|
||||
## 安装步骤
|
||||
|
||||
### 添加 Gitea 包仓库
|
||||
|
||||
```bash
|
||||
# 导入 Gitea 仓库密钥
|
||||
sudo curl https://GITEA_URL/api/packages/OWNER/debian/repository.key \
|
||||
-o /etc/apt/keyrings/gitea-OWNER.asc
|
||||
|
||||
# 添加仓库源(以 Debian 12 为例)
|
||||
echo "deb [signed-by=/etc/apt/keyrings/gitea-OWNER.asc] \
|
||||
https://GITEA_URL/api/packages/OWNER/debian bookworm main" | \
|
||||
sudo tee /etc/apt/sources.list.d/OWNER.list
|
||||
|
||||
# 更新包列表并安装
|
||||
sudo apt-get update
|
||||
sudo apt-get install p2pool
|
||||
```
|
||||
|
||||
## 配置 P2Pool
|
||||
|
||||
### 编辑配置文件
|
||||
|
||||
P2Pool 使用配置文件 `/var/lib/p2pool/params.conf` 来管理所有设置。安装后会自动创建示例配置文件。
|
||||
|
||||
```bash
|
||||
# 编辑配置文件
|
||||
sudo nano /var/lib/p2pool/params.conf
|
||||
```
|
||||
|
||||
配置文件示例:
|
||||
```conf
|
||||
# P2Pool Configuration File
|
||||
|
||||
# Monero node connection
|
||||
host = 127.0.0.1
|
||||
rpc-port = 18081
|
||||
zmq-port = 18083
|
||||
|
||||
# Your Monero wallet address (REQUIRED)
|
||||
wallet = YOUR_MONERO_WALLET_ADDRESS
|
||||
|
||||
# P2P settings
|
||||
p2p = 0.0.0.0:37889
|
||||
|
||||
# API settings
|
||||
data-api = /var/lib/p2pool/data-api
|
||||
local-api = true
|
||||
|
||||
# Logging
|
||||
log-file = /var/log/p2pool/p2pool.log
|
||||
loglevel = 3
|
||||
|
||||
# Mining mode (uncomment to enable mini sidechain)
|
||||
# mini = true
|
||||
|
||||
# Stratum server (for miners to connect)
|
||||
# stratum = 0.0.0.0:3333
|
||||
```
|
||||
|
||||
### 关键配置参数
|
||||
|
||||
- `host`:Monero 节点的 IP 地址
|
||||
- `rpc-port`:Monero 节点的 RPC 端口
|
||||
- `zmq-port`:Monero 节点的 ZMQ 端口
|
||||
- `wallet`:**必需** - 您的 Monero 钱包地址
|
||||
- `mini`:启用 mini 侧链(适合算力较小的矿工)
|
||||
- `stratum`:Stratum 服务器地址,供矿机连接
|
||||
- `loglevel`:日志级别(0-6,3 为默认值)
|
||||
|
||||
### 配置文件的优势
|
||||
|
||||
- ✅ **版本升级安全**:`params.conf` 在 `apt upgrade` 时不会被覆盖
|
||||
- ✅ **易于管理**:所有配置集中在一个文件中
|
||||
- ✅ **支持注释**:可以添加说明和注释
|
||||
- ✅ **无需修改 systemd**:避免编辑系统服务文件
|
||||
|
||||
## 启动和管理服务
|
||||
|
||||
```bash
|
||||
# 启用服务,设置开机自启
|
||||
sudo systemctl enable p2pool.service
|
||||
|
||||
# 启动服务
|
||||
sudo systemctl start p2pool.service
|
||||
|
||||
# 查看服务状态
|
||||
sudo systemctl status p2pool.service
|
||||
|
||||
# 查看实时日志
|
||||
sudo journalctl -u p2pool -f
|
||||
```
|
||||
|
||||
## 目录结构
|
||||
|
||||
- `/opt/p2pool/p2pool`:P2Pool 二进制文件
|
||||
- `/var/lib/p2pool/`:数据目录
|
||||
- `/var/log/p2pool/`:日志目录
|
||||
|
||||
## 安全建议
|
||||
|
||||
- 使用专用钱包地址
|
||||
- 限制 Stratum 端口的网络访问
|
||||
- 定期更新 p2pool 版本
|
||||
|
||||
## 故障排查
|
||||
|
||||
### 常见错误
|
||||
|
||||
- RPC 端口配置不正确
|
||||
- 钱包地址无效
|
||||
- 网络连接问题
|
||||
|
||||
### 检查日志
|
||||
|
||||
```bash
|
||||
# 查看完整日志
|
||||
sudo cat /var/log/p2pool/p2pool.log
|
||||
|
||||
# 查看最近错误
|
||||
sudo journalctl -u p2pool -n 50 --no-pager
|
||||
```
|
||||
|
||||
## 版本管理
|
||||
|
||||
```bash
|
||||
# 查看当前版本
|
||||
/opt/p2pool/p2pool --version
|
||||
|
||||
# 检查可用更新
|
||||
sudo apt-get update
|
||||
sudo apt-cache policy p2pool
|
||||
```
|
||||
88
llmdoc/guides/local-build.md
Normal file
88
llmdoc/guides/local-build.md
Normal file
@@ -0,0 +1,88 @@
|
||||
# 本地构建指南
|
||||
|
||||
## 准备工作
|
||||
|
||||
### 系统依赖
|
||||
- Docker
|
||||
- Docker Buildx
|
||||
- Git
|
||||
|
||||
### 安装 Docker Buildx
|
||||
|
||||
```bash
|
||||
# 启用 QEMU(支持多平台构建)
|
||||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
|
||||
# 创建 buildx builder
|
||||
docker buildx create --use --name p2pool_builder --driver docker-container
|
||||
docker buildx inspect --bootstrap
|
||||
```
|
||||
|
||||
## 构建二进制包
|
||||
|
||||
### Alpine 构建(推荐)
|
||||
|
||||
```bash
|
||||
# 构建单一架构
|
||||
docker buildx build --pull \
|
||||
--platform linux/amd64 \
|
||||
--build-arg P2POOL_VERSION=v4.9.1 \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile.alpine .
|
||||
|
||||
# 多架构构建
|
||||
docker buildx build --pull \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
--build-arg P2POOL_VERSION=v4.9.1 \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile.alpine .
|
||||
```
|
||||
|
||||
### Ubuntu 构建
|
||||
|
||||
```bash
|
||||
docker buildx build --pull \
|
||||
--platform linux/amd64 \
|
||||
--build-arg P2POOL_VERSION=v4.9.1 \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile.ubuntu .
|
||||
```
|
||||
|
||||
## 构建 Debian 包
|
||||
|
||||
```bash
|
||||
# 打包二进制文件
|
||||
TARGZ="p2pool-amd64-ubuntu-v4.12.tar.gz"
|
||||
tar -czf "${TARGZ}" -C ./output/linux_amd64 .
|
||||
|
||||
# 生成 Debian 包
|
||||
./debian/build-deb.sh amd64 v4.12 "${TARGZ}"
|
||||
```
|
||||
|
||||
## 常见问题排查
|
||||
|
||||
### 调整编译并行度
|
||||
|
||||
修改 Dockerfile 中的 `MAKE_JOBS` 变量:
|
||||
|
||||
```dockerfile
|
||||
# 使用全部 CPU 核心(amd64)
|
||||
elif [ "$TARGETARCH" = "amd64" ]; then \
|
||||
MAKE_JOBS="-j$(nproc)";
|
||||
|
||||
# 或使用固定作业数
|
||||
elif [ "$TARGETARCH" = "amd64" ]; then \
|
||||
MAKE_JOBS="-j4";
|
||||
```
|
||||
|
||||
### 网络和依赖问题
|
||||
|
||||
- 确保 Docker 可以访问互联网
|
||||
- 检查 Git 子模块是否正确初始化
|
||||
- 验证 CMake 和编译器版本兼容性
|
||||
|
||||
## 性能提示
|
||||
|
||||
- 使用 SSD 提高构建速度
|
||||
- 保持 Docker 镜像和依赖更新
|
||||
- 对于大型项目,考虑使用构建缓存
|
||||
12
llmdoc/index.md
Normal file
12
llmdoc/index.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# P2Pool Debian 打包与配置系统文档
|
||||
|
||||
## 文档导航
|
||||
|
||||
### 总览
|
||||
- [架构:Debian 包管理](/llmdoc/architecture/debian-packaging.md)
|
||||
|
||||
### 指南
|
||||
- [Debian 包安装与配置](/llmdoc/guides/debian-package.md)
|
||||
|
||||
### 参考资料
|
||||
- 待添加
|
||||
45
llmdoc/overview/project-overview.md
Normal file
45
llmdoc/overview/project-overview.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# 项目概述:P2Pool Docker 构建基础设施
|
||||
|
||||
## 项目背景
|
||||
|
||||
P2Pool 是一个去中心化的 Monero 矿池,本项目旨在提供一个标准化、可靠的构建和打包基础设施。
|
||||
|
||||
## 主要目标
|
||||
|
||||
1. 自动化构建 p2pool 二进制包
|
||||
2. 支持多架构(amd64, arm64)
|
||||
3. 生成 Debian 和通用包
|
||||
4. 禁用合并挖矿捐赠功能
|
||||
|
||||
## 构建输出
|
||||
|
||||
- **二进制包**:
|
||||
- amd64 架构
|
||||
- arm64 架构
|
||||
- **包格式**:
|
||||
- tar.gz 压缩包
|
||||
- Debian 包(.deb)
|
||||
- **构建基础镜像**:
|
||||
- Alpine Linux (推荐)
|
||||
- Ubuntu LTS
|
||||
|
||||
## 关键特性
|
||||
|
||||
- 使用 Docker 多阶段构建
|
||||
- 通过 Gitea Actions 自动化 CI/CD
|
||||
- 支持版本化构建
|
||||
- 原生架构构建,性能优化
|
||||
- 自动包发布到 Gitea 包仓库
|
||||
|
||||
## 版本管理
|
||||
|
||||
- 直接从 [SChernykh/p2pool](https://github.com/SChernykh/p2pool) 上游仓库构建
|
||||
- 通过 `P2POOL_VERSION` 环境变量控制构建版本
|
||||
- 使用 Git 标签管理版本发布
|
||||
|
||||
## 使用限制
|
||||
|
||||
- 不包含 p2pool 源代码
|
||||
- 构建时需要互联网连接
|
||||
- 依赖 Docker Buildx
|
||||
- 需要配置钱包地址才能运行服务
|
||||
59
llmdoc/reference/coding-conventions.md
Normal file
59
llmdoc/reference/coding-conventions.md
Normal file
@@ -0,0 +1,59 @@
|
||||
# 编码规范
|
||||
|
||||
## Shell 脚本规范
|
||||
|
||||
### 基本原则
|
||||
- 使用 `#!/bin/sh` 作为脚本头
|
||||
- 遵循 POSIX shell 标准
|
||||
- 避免使用 Bash 特定语法
|
||||
|
||||
### 缩进与格式
|
||||
- 使用 4 个空格缩进
|
||||
- 每个代码块使用一致的缩进
|
||||
- 长行使用 `\` 换行
|
||||
|
||||
### 变量使用
|
||||
- 使用双引号包裹变量:`"$VARIABLE"`
|
||||
- 避免未定义变量
|
||||
- 使用 `${VARIABLE:-default}` 设置默认值
|
||||
|
||||
### 示例
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# 变量定义
|
||||
P2POOL_VERSION="${1:-v4.9.1}"
|
||||
OUTPUT_DIR="${2:-./output}"
|
||||
|
||||
# 函数定义
|
||||
build_p2pool() {
|
||||
local arch="$1"
|
||||
local distro="$2"
|
||||
|
||||
docker buildx build --pull \
|
||||
--platform "linux/${arch}" \
|
||||
--build-arg "P2POOL_VERSION=${P2POOL_VERSION}" \
|
||||
--output "type=local,dest=${OUTPUT_DIR}" \
|
||||
-f "docker/Dockerfile.${distro}" .
|
||||
}
|
||||
|
||||
# 主逻辑
|
||||
main() {
|
||||
build_p2pool "amd64" "alpine"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
```
|
||||
|
||||
## Docker 文件规范
|
||||
- 遵循多阶段构建
|
||||
- 尽量减少镜像层数
|
||||
- 使用多架构构建
|
||||
- 避免在构建过程中下载可变内容
|
||||
|
||||
## Git 提交规范
|
||||
- 使用清晰、简洁的提交信息
|
||||
- 提交信息应描述**为什么**做这个改动
|
||||
- 使用动词开头:添加(Add)、修复(Fix)、优化(Improve)等
|
||||
79
llmdoc/reference/git-conventions.md
Normal file
79
llmdoc/reference/git-conventions.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# Git 协作规范
|
||||
|
||||
## 分支管理
|
||||
|
||||
### 主分支
|
||||
- `main`: 稳定版本
|
||||
- `develop`: 开发分支
|
||||
|
||||
### 开发流程
|
||||
1. 从 `develop` 创建功能分支
|
||||
2. 功能分支命名规范:
|
||||
- `feature/` 前缀表示新功能
|
||||
- `bugfix/` 前缀表示 bug 修复
|
||||
- `docs/` 前缀表示文档更新
|
||||
|
||||
### 示例分支创建
|
||||
```bash
|
||||
# 从 develop 创建功能分支
|
||||
git checkout develop
|
||||
git pull origin develop
|
||||
git checkout -b feature/add-architecture-docs
|
||||
```
|
||||
|
||||
## 提交规范
|
||||
|
||||
### 提交信息格式
|
||||
```
|
||||
<类型>: <简要描述>
|
||||
|
||||
[可选的详细说明]
|
||||
|
||||
[关联的 issue 或 PR]
|
||||
```
|
||||
|
||||
### 类型定义
|
||||
- `feat`: 新功能
|
||||
- `fix`: 修复 bug
|
||||
- `docs`: 文档更新
|
||||
- `style`: 代码风格调整
|
||||
- `refactor`: 重构
|
||||
- `test`: 测试相关
|
||||
- `build`: 构建系统或外部依赖变更
|
||||
- `ci`: CI 配置变更
|
||||
|
||||
### 提交示例
|
||||
```bash
|
||||
docs: 添加 p2pool 构建文档系统
|
||||
|
||||
- 创建 llmdoc 目录结构
|
||||
- 添加项目概述文档
|
||||
- 编写编码和 Git 规范文档
|
||||
|
||||
关联 Issue: #123
|
||||
```
|
||||
|
||||
## 代码审查
|
||||
|
||||
### 合并请求(PR)规范
|
||||
- 所有 PR 必须从功能分支提交到 `develop`
|
||||
- PR 标题应简洁描述变更
|
||||
- PR 描述必须包含:
|
||||
1. 变更的目的
|
||||
2. 具体实现
|
||||
3. 测试方法
|
||||
- 至少需要一个审查者批准
|
||||
|
||||
## 版本标签
|
||||
|
||||
### 版本命名
|
||||
- 使用语义化版本 (Semantic Versioning)
|
||||
- 格式:`vMAJOR.MINOR.PATCH`
|
||||
- 示例:`v4.12.0`
|
||||
|
||||
### 发布流程
|
||||
```bash
|
||||
# 创建版本标签
|
||||
git tag v4.12.0
|
||||
git push origin v4.12.0
|
||||
```
|
||||
84
params.conf.example
Normal file
84
params.conf.example
Normal file
@@ -0,0 +1,84 @@
|
||||
# P2Pool Configuration File Example
|
||||
# Copy this file to /var/lib/p2pool/params.conf and edit as needed
|
||||
|
||||
# =============================================================================
|
||||
# Monero Node Connection (REQUIRED)
|
||||
# =============================================================================
|
||||
# IP address or hostname of your Monero node
|
||||
host = 127.0.0.1
|
||||
|
||||
# Monero RPC port
|
||||
rpc-port = 18081
|
||||
|
||||
# Monero ZMQ port (required for optimal performance)
|
||||
zmq-port = 18083
|
||||
|
||||
# =============================================================================
|
||||
# Wallet Configuration (REQUIRED)
|
||||
# =============================================================================
|
||||
# Your Monero wallet address - THIS IS REQUIRED
|
||||
# Replace with your actual wallet address
|
||||
wallet = YOUR_MONERO_WALLET_ADDRESS
|
||||
|
||||
# =============================================================================
|
||||
# P2P Network Settings
|
||||
# =============================================================================
|
||||
# P2P bind address and port for P2Pool network communication
|
||||
p2p = 0.0.0.0:37889
|
||||
|
||||
# Add known peer nodes (optional)
|
||||
# addpeers = node1.p2pool.io:37889,node2.p2pool.io:37889
|
||||
|
||||
# =============================================================================
|
||||
# API Settings
|
||||
# =============================================================================
|
||||
# Directory for data API files
|
||||
data-api = /var/lib/p2pool/data-api
|
||||
|
||||
# Enable local API (recommended for monitoring)
|
||||
local-api = true
|
||||
|
||||
# =============================================================================
|
||||
# Mining Mode
|
||||
# =============================================================================
|
||||
# Use mini sidechain for smaller miners (lower difficulty)
|
||||
# Uncomment if your hashrate is less than 50 KH/s
|
||||
# mini = true
|
||||
|
||||
# =============================================================================
|
||||
# Stratum Server (for connecting miners)
|
||||
# =============================================================================
|
||||
# Enable stratum server for miners to connect
|
||||
# Format: <bind_ip>:<port>
|
||||
# Uncomment and configure if you want to connect mining software
|
||||
# stratum = 0.0.0.0:3333
|
||||
|
||||
# =============================================================================
|
||||
# Merge Mining (Optional)
|
||||
# =============================================================================
|
||||
# Enable Tari merge mining
|
||||
# Format: tari://<tari_node_ip>:<port> <tari_wallet_address>
|
||||
# Uncomment and configure if you want to merge mine Tari
|
||||
# merge-mine = tari://127.0.0.1:18142 YOUR_TARI_WALLET_ADDRESS
|
||||
|
||||
# =============================================================================
|
||||
# Logging
|
||||
# =============================================================================
|
||||
# Log file location
|
||||
log-file = /var/log/p2pool/p2pool.log
|
||||
|
||||
# Log level (0 = none, 1 = fatal, 2 = error, 3 = warn, 4 = info, 5 = debug, 6 = trace)
|
||||
loglevel = 3
|
||||
|
||||
# =============================================================================
|
||||
# Performance Tuning (Advanced)
|
||||
# =============================================================================
|
||||
# Number of light cache blocks to keep in RAM
|
||||
# in-peers = 10
|
||||
# out-peers = 10
|
||||
|
||||
# =============================================================================
|
||||
# Network Settings (Advanced)
|
||||
# =============================================================================
|
||||
# SOCKS5 proxy for outgoing connections
|
||||
# socks5 = 127.0.0.1:9050
|
||||
Reference in New Issue
Block a user