Compare commits
10
Commits
8f7cca95fe
...
4.17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34aa4f8c74 | ||
|
|
1f92188b59 | ||
|
|
1ecf2ca151 | ||
|
|
b98a915df3 | ||
|
|
3b024fdc10 | ||
|
|
b222b802bf | ||
|
|
2599d203bb | ||
|
|
e4f8a390bb | ||
|
|
676984ba8e | ||
|
|
961b2d3702 |
+45
-17
@@ -9,7 +9,7 @@ on:
|
||||
env:
|
||||
DOCKER_BUILDKIT: "1"
|
||||
PRODUCT_NAME: "p2pool"
|
||||
PACKAGE_VERSION: "v4.13"
|
||||
PACKAGE_VERSION: "4.17"
|
||||
BUILDX_NO_DEFAULT_ATTESTATIONS: "1"
|
||||
|
||||
jobs:
|
||||
@@ -18,7 +18,6 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [amd64, arm64]
|
||||
distro: [ubuntu, alpine]
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -35,11 +34,10 @@ jobs:
|
||||
|
||||
- name: Build binaries
|
||||
run: |
|
||||
P2POOL_VERSION=${PACKAGE_VERSION}
|
||||
PLATFORM="linux/${{ matrix.arch }}"
|
||||
P2POOL_VERSION="v${PACKAGE_VERSION}" # 上游 p2pool git tag 带 v 前缀,需补回
|
||||
|
||||
echo "🏗️ Building ${PLATFORM} on native ${{ matrix.arch }} runner"
|
||||
echo "📦 Distribution: ${{ matrix.distro }}"
|
||||
echo "🏗️ Building ${PLATFORM} on native ${{ matrix.arch }} runner (musl 纯静态)"
|
||||
|
||||
# 设置 BuildKit 优化参数
|
||||
export BUILDKIT_PROGRESS=plain
|
||||
@@ -48,7 +46,7 @@ jobs:
|
||||
--platform ${PLATFORM} \
|
||||
--build-arg P2POOL_VERSION=${P2POOL_VERSION} \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile.${{ matrix.distro }} .
|
||||
-f docker/Dockerfile .
|
||||
|
||||
- name: Package and test
|
||||
run: |
|
||||
@@ -59,24 +57,30 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-${{ matrix.distro }}-${PACKAGE_VERSION}.tar.gz"
|
||||
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-linux-static-${PACKAGE_VERSION}.tar.gz"
|
||||
tar -czf "${TARGZ}" -C "$DIR" .
|
||||
|
||||
echo "📦 Created package: ${TARGZ}"
|
||||
ls -lh "${TARGZ}"
|
||||
|
||||
# 快速验证
|
||||
# 快速验证:--help 冒烟 + ldd 纯静态校验(musl 静态可在 glibc runner 直接跑)
|
||||
mkdir -p test && tar -xzf "${TARGZ}" -C test
|
||||
test/p2pool --help 2>/dev/null || echo "⚠️ Help displayed"
|
||||
test/p2pool --help >/dev/null 2>&1 && echo "✅ --help OK" || echo "⚠️ --help 退出非0"
|
||||
# ldd 对纯静态二进制返回 exit 1,须先捕获输出再判定(run 块是 bash -e -o pipefail,直接管道会被误杀)
|
||||
LDD_OUT=$(ldd test/p2pool 2>&1 || true)
|
||||
if echo "$LDD_OUT" | grep -qE 'statically linked|not a dynamic executable'; then
|
||||
echo "✅ fully-static(无动态依赖,跨发行版)"
|
||||
else
|
||||
echo "⚠️ 非纯静态:"; echo "$LDD_OUT"; exit 1
|
||||
fi
|
||||
rm -rf test
|
||||
|
||||
- name: Build Debian package
|
||||
if: matrix.distro == 'ubuntu'
|
||||
run: |
|
||||
# 安装 dpkg-deb(如果需要)
|
||||
sudo apt-get update && sudo apt-get install -y dpkg-dev
|
||||
|
||||
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-${{ matrix.distro }}-${PACKAGE_VERSION}.tar.gz"
|
||||
TARGZ="${PRODUCT_NAME}-${{ matrix.arch }}-linux-static-${PACKAGE_VERSION}.tar.gz"
|
||||
|
||||
echo "📦 Building Debian package for ${{ matrix.arch }}..."
|
||||
chmod +x debian/build-deb.sh
|
||||
@@ -86,7 +90,7 @@ jobs:
|
||||
|
||||
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: binaries-${{ matrix.arch }}-${{ matrix.distro }}
|
||||
name: binaries-${{ matrix.arch }}
|
||||
path: |
|
||||
*.tar.gz
|
||||
*.deb
|
||||
@@ -114,12 +118,13 @@ jobs:
|
||||
REGISTRY=$(echo "${{ gitea.server_url }}" | sed 's|https\?://||')
|
||||
OWNER="${{ gitea.repository_owner }}"
|
||||
REPO_NAME=$(echo "${{ gitea.repository }}" | cut -d'/' -f2)
|
||||
VERSION="${TAG#v}" # 包版本:去掉 git tag 的 v 前缀(registry 路径/下载名/Release 标题统一用纯数字)
|
||||
|
||||
echo "📦 上传包到 Generic Package Registry..."
|
||||
echo " Registry: ${REGISTRY}"
|
||||
echo " Owner: ${OWNER}"
|
||||
echo " Package: ${PRODUCT_NAME}"
|
||||
echo " Version: ${TAG}"
|
||||
echo " Version: ${VERSION}"
|
||||
|
||||
# 上传所有 tar.gz 包到 Generic Package Registry
|
||||
for file in *.tar.gz; do
|
||||
@@ -128,7 +133,7 @@ jobs:
|
||||
curl -fsSL -X PUT \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
--upload-file "$file" \
|
||||
"https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${TAG}/$file" || {
|
||||
"https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${VERSION}/$file" || {
|
||||
echo "❌ 上传失败: $file"
|
||||
exit 1
|
||||
}
|
||||
@@ -151,12 +156,35 @@ jobs:
|
||||
}
|
||||
done
|
||||
|
||||
# 生成 Release JSON payload
|
||||
# 生成 Release 描述
|
||||
echo ""
|
||||
echo "📝 生成 Release..."
|
||||
|
||||
export REGISTRY OWNER TAG
|
||||
RELEASE_DATA=$(python3 -c 'import json,glob,os;r=os.environ["REGISTRY"];o=os.environ["OWNER"];p=os.environ["PRODUCT_NAME"];t=os.environ["TAG"];b=["## Release "+t,"","### 📥 下载方式","","#### 方式 1: 直接下载(推荐)","","点击下面 **Assets** 部分的文件名直接下载。","","#### 方式 2: Generic Package Registry",""]+[f"- [`{f}`](https://{r}/api/packages/{o}/generic/{p}/{t}/{f})" for f in sorted(glob.glob("*.tar.gz"))]+["","#### 方式 3: Debian Repository","","```bash","# Download GPG key",f"sudo curl https://{r}/api/packages/{o}/debian/repository.key -o /etc/apt/keyrings/gitea-{o}.asc","","# Add repository",f"echo \"deb [signed-by=/etc/apt/keyrings/gitea-{o}.asc] https://{r}/api/packages/{o}/debian stable main\" | sudo tee -a /etc/apt/sources.list.d/{o}.list","","# Update and install","sudo apt-get update",f"sudo apt-get install {p}","```"];print(json.dumps({"tag_name":t,"name":f"Release {t}","body":"\n".join(b),"draft":False,"prerelease":False}))')
|
||||
# 拼接 tar.gz 下载链接
|
||||
ASSETS=$(for f in *.tar.gz; do
|
||||
[ -f "$f" ] || continue
|
||||
echo "- [\`$f\`](https://${REGISTRY}/api/packages/${OWNER}/generic/${PRODUCT_NAME}/${VERSION}/$f)"
|
||||
done)
|
||||
|
||||
BODY=$(cat <<EOF
|
||||
## Release ${VERSION}
|
||||
|
||||
### 📥 Debian/Ubuntu 安装
|
||||
|
||||
\`\`\`bash
|
||||
sudo curl https://${REGISTRY}/api/packages/${OWNER}/debian/repository.key -o /etc/apt/keyrings/gitea-${OWNER}.asc
|
||||
echo "deb [signed-by=/etc/apt/keyrings/gitea-${OWNER}.asc] https://${REGISTRY}/api/packages/${OWNER}/debian stable main" | sudo tee /etc/apt/sources.list.d/${OWNER}.list
|
||||
sudo apt-get update && sudo apt-get install ${PRODUCT_NAME}
|
||||
\`\`\`
|
||||
|
||||
### 📦 tar.gz 下载
|
||||
|
||||
${ASSETS}
|
||||
EOF
|
||||
)
|
||||
|
||||
RELEASE_DATA=$(jq -n --arg tag "$TAG" --arg ver "$VERSION" --arg body "$BODY" \
|
||||
'{tag_name: $tag, name: "Release \($ver)", body: $body, draft: false, prerelease: false}')
|
||||
|
||||
# 创建 Release
|
||||
echo ""
|
||||
|
||||
+4
-3
@@ -1,6 +1,7 @@
|
||||
.DS_Store
|
||||
|
||||
.idea/
|
||||
.vscode/
|
||||
|
||||
.claude/
|
||||
CLAUDE.md
|
||||
docs/
|
||||
example/
|
||||
.codex/
|
||||
@@ -0,0 +1,62 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## 仓库性质
|
||||
|
||||
本仓库**只包含构建与打包基础设施**,不含 p2pool 源码。源码在编译时从上游克隆(见 [docker/Dockerfile](docker/Dockerfile)):
|
||||
|
||||
- 源码仓库:`github.com/SChernykh/p2pool.git`(**p2pool 官方仓库**,非换名)
|
||||
- 发布仓库:Gitea `gitea.bcde.io` 下 `wangdefa/p2pool` 的 Generic / Debian 包仓库
|
||||
|
||||
p2pool 是 Monero 去中心化矿池的 sidechain 节点。本项目对上游唯一的定制是 **`-DWITH_MERGE_MINING_DONATION=OFF`**(禁用合并挖矿捐赠),不改源码。
|
||||
|
||||
> **与同目录 `gitea-xxxig` / `gitea-xxxig-proxy` / `gitea-mond` 的关系**:四者共享同一套 CI / build-deb / debian 打包骨架,且均为 **musl fully-static** 构建。差异:xxxig 系是 XMRig 换名仓库源码;mond 克隆 Monero 官方靠 init.sh 现场换名;p2pool 直接构建官方源码、不换名,版本号纯数字(`4.17`,上游 git tag 带 v、构建时补回)。
|
||||
|
||||
## 整体架构:单二进制
|
||||
|
||||
编译产出单个可执行文件 `p2pool`:连接 monerod(本地,或经 `--rpc-ssl` 连外部 SSL 节点)、维护 P2Pool sidechain、提供 stratum 给矿工。配置模板 [conf/params.conf.example](conf/params.conf.example)。
|
||||
|
||||
## 构建与发布流程(CI)
|
||||
|
||||
[.gitea/workflows/ci.yaml](.gitea/workflows/ci.yaml) 是 Gitea Actions 流水线:
|
||||
|
||||
1. **build-and-test**(矩阵 `arch=[amd64,arm64]`,跑在对应架构原生 runner):用 `docker buildx` 按 [docker/Dockerfile](docker/Dockerfile) 原生编译 → 打成 tar.gz → 解包冒烟(`p2pool --help` + `ldd` 纯静态校验)→ 调 `debian/build-deb.sh` 打 .deb → 上传 artifact。
|
||||
2. **release**(仅 tag 触发):下载 artifact,上传 tar.gz 到 Generic Package Registry、上传 .deb 到 Debian Registry(stable/main),并用 python3 生成描述创建 Gitea Release。
|
||||
|
||||
关键点:
|
||||
- **musl fully-static(Alpine 构建,勿改回 glibc)**:上游 p2pool **官方 release 二进制即用此法**(见上游 `.github/workflows/c-cpp.yml` 的 Alpine static job)。[docker/Dockerfile](docker/Dockerfile) 在 `alpine:3.21` 下自编 external 静态库(curl/libuv/libzmq)+ 静态 grpc 栈(含 boringssl,`WITH_GRPC=ON` 支持 Tari 合并挖矿),再 `-DSTATIC_BINARY=ON` 全静态。产物 `ldd` = `not a dynamic executable`、零外部依赖,**glibc/musl 任意发行版直接运行**(实测 musl 产物在 Debian 13 上正常 `--help`)。
|
||||
- **为何用 musl 而非 glibc**:musl 的 `getaddrinfo` 自带实现,全静态也能解析 DNS;glibc 静态会因 NSS 运行时 `dlopen` 失败。与 `gitea-xxxig`/`gitea-xxxig-proxy`/`gitea-mond` 一致。曾用的 `Dockerfile.ubuntu`(glibc 动态)与 `Dockerfile.alpine`(动态链 system 库)均已删除。
|
||||
- **依赖处理(关键,勿乱改)**:
|
||||
- external 依赖**子模块自带源码**,逐个编静态(`BUILD_SHARED_LIBS=OFF` 等)。拉 8 个常规子模块 + grpc 及其 **6 个必需 third_party**(`abseil-cpp`/`boringssl-with-bazel`/`cares`/`protobuf`/`re2`/`zlib`);其余 9 个 grpc 子模块(benchmark/googletest/envoy/googleapis/xds 等测试或 xDS 依赖,已 `GRPC_NO_XDS`)**跳过**省体积/时间。
|
||||
- **WITH_GRPC=ON(支持 Tari 合并挖矿,勿改回 OFF)**:上游 CMake 默认即 ON(官方 alpine static job 为省体积改 OFF,本项目恢复 ON)。ON 时 `cmake/grpc.cmake` 用 `add_subdirectory(external/src/grpc)` 自动静态编译 grpc/protobuf/abseil/re2/cares,并 `add_subdirectory(external/src/Tari)` 编 checked-in 的 Tari proto(`.pb.cc`,不需运行时 protoc),链接 `Tari_gRPC grpc grpc++ libprotobuf`。这样 `tari://` 主机走 `MergeMiningClientTari`(gRPC)而非 `MergeMiningClientJSON_RPC`(JSON-RPC,与 Tari 不兼容、报 `empty response`)。代价:二进制 ~5MB→~15MB(`-Wl,-s --gc-sections` 剔除未用 grpc/xDS 代码后远小于全量)、构建 +约 15min/arch。曾为省体积误用 `WITH_GRPC=OFF` 致无法与 Tari 合并挖矿,**已改回 ON,勿回退**。
|
||||
- **boringssl 来源**:`WITH_GRPC=ON` 时由 grpc 子模块(`third_party/boringssl-with-bazel`)提供,grpc.cmake 走此分支、**不再** `add_subdirectory(cmake/ssl)`(那是 `elseif (WITH_TLS)` 分支);p2pool 主体 TLS 与下方 curl 共用这一份 boringssl。
|
||||
- **curl 用 boringssl TLS(保留 rpc-ssl,勿改回 no-SSL)**:完整照搬官方 `c-cpp.yml` 的 curl flags——`P2POOL_BORINGSSL=ON`(上游给 curl 的独立 boringssl 后端补丁,与 `CURL_ENABLE_SSL=OFF` 共存、不走 curl 标准 SSL 路径)+ 一整套 `CURL_DISABLE_*`(尤其 `SRP`/`AWS`/`*_AUTH`)。后者跳过会引用 `OpenSSL::SSL` imported target 的 `curl_openssl_check_exists` 符号检测(新版 cmake 在 `try_compile` 阶段校验该 target 必失败,**少一个 disable 都会触发**)。curl 与 p2pool 主体共用同一 boringssl,`json_rpc_request` 的 `CURLOPT_SSL_CTX_FUNCTION` 才能接管证书指纹校验——**`--rpc-ssl`/`--rpc-ssl-fingerprint` 连外部 SSL monerod 的能力得以保留**(已实测连真实 SSL 节点用 `--rpc-ssl` 拿到链上高度)。曾误用 no-SSL curl 会断此能力,勿回退。
|
||||
- **版本号约定**:包版本硬编码在 ci.yaml 的 `PACKAGE_VERSION: "4.17"`(**纯数字、无 v**,符合 Debian 版本规范)。**关键分界**:上游 p2pool git tag 带 `v`,故 build job 用 `P2POOL_VERSION="v${PACKAGE_VERSION}"` 补回 v 传给 Dockerfile `git checkout`;tar.gz / deb / registry 路径 / Release 标题等包版本一律直接用 `${PACKAGE_VERSION}`;release job 用 `VERSION="${TAG#v}"` 归一(tag 带不带 v 都兼容,唯 Release 的 `tag_name` 用 git tag 原值)。CI 触发条件 `tags: ['*']`,发版改 `PACKAGE_VERSION` 并打对应 tag(纯数字,如 `4.17`)。
|
||||
- 架构映射:Dockerfile 内 `arm64→ARCH_ID=aarch64`、`amd64→ARCH_ID=x86_64`(传给 p2pool cmake,控制 RandomX 优化)。
|
||||
- tar.gz 下载 URL 形如 `https://gitea.bcde.io/api/packages/wangdefa/generic/p2pool/{version}/p2pool-{arch}-linux-static-{version}.tar.gz`(version 为纯数字)。
|
||||
|
||||
## 本地常用命令
|
||||
|
||||
```bash
|
||||
# 本地编译某架构的二进制(输出到 ./output/linux_<arch>/p2pool)
|
||||
docker buildx build --platform linux/amd64 \
|
||||
--build-arg P2POOL_VERSION=v4.17 \
|
||||
--output type=local,dest=./output \
|
||||
-f docker/Dockerfile .
|
||||
|
||||
# 校验纯静态(应输出 "not a dynamic executable")
|
||||
ldd output/linux_amd64/p2pool
|
||||
|
||||
# 用已有 tar.gz 打 .deb 包(第三个参数是 tar.gz)
|
||||
./debian/build-deb.sh amd64 4.17 p2pool-amd64-linux-static-4.17.tar.gz
|
||||
```
|
||||
|
||||
无单元测试;CI 唯一冒烟是解包后跑 `p2pool --help`(musl 纯静态可在 glibc runner 直接运行),并用 `ldd` 校验为纯静态。
|
||||
|
||||
## Debian 包布局与服务
|
||||
|
||||
- 二进制装到 `/opt/p2pool/p2pool`,systemd 服务 [debian/p2pool.service](debian/p2pool.service),维护脚本 `debian/{postinst,prerm,postrm}`。
|
||||
- **配置流转(单一数据源,对齐 gitea-mond)**:`conf/params.conf.example` 是唯一配置源 → build-deb.sh 复制进包内 `/opt/p2pool/params.conf` → postinst 首次安装时 `cp` 到 `/etc/p2pool/params.conf`(**升级不覆盖**用户已有配置;旧版本位于 `/var/lib/p2pool/params.conf` 时 postinst 自动迁移到 `/etc/p2pool/`)。service 的 `ExecStart` 用 `--params-file /etc/p2pool/params.conf`。**改默认配置改 conf/params.conf.example 一处即可**(不要再在 postinst 内联 heredoc)。
|
||||
- 数据目录 `/var/lib/p2pool/data-api`、日志目录 `/var/log/p2pool`,均归 `p2pool` 系统用户。postinst 创建 `p2pool` 系统用户/组,**服务不自动启用/启动**(首次需用户配置钱包地址),升级时若服务原为 enabled 则重启加载新二进制。
|
||||
- control.template **无 `Depends` 字段**(纯静态,连 libc6/libuv1/libzmq5/libcurl4 都不需要)。
|
||||
@@ -1,113 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
@@ -1,132 +1,91 @@
|
||||
# P2Pool Docker 构建基础设施
|
||||
# P2Pool
|
||||
|
||||
[]()
|
||||
[]()
|
||||
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 + 内置 gRPC,无外部动态库依赖,任意 Linux 发行版可跑):
|
||||
|
||||
**关键特性**:
|
||||
- 🏗️ 多架构支持(amd64、arm64)
|
||||
- 📦 多发行版构建(Alpine、Ubuntu)
|
||||
- 🤖 全自动 CI/CD 流程
|
||||
- 🔒 禁用合并挖矿捐赠
|
||||
- 📊 原生架构构建(无 QEMU)
|
||||
| 二进制 | 作用 |
|
||||
|---|---|
|
||||
| `p2pool` | P2Pool sidechain 节点:连接 monerod、维护 sidechain、向矿工提供 stratum;支持与 Tari 合并挖矿 |
|
||||
|
||||
## 🚀 快速开始
|
||||
支持架构 `amd64` / `arm64`;musl 纯静态,任意 Linux 发行版(Debian/Ubuntu/Alpine/CentOS 等)开箱即跑。静态构建仍保留 `--rpc-ssl`(连外部 SSL monerod 节点)与内置 gRPC(`--merge-mine tari://...` 与 Tari 合并挖矿)。
|
||||
|
||||
### Debian/Ubuntu(推荐)
|
||||
## 安装
|
||||
|
||||
### APT(Debian / 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.17/p2pool-amd64-linux-static-4.17.tar.gz
|
||||
tar -xzf p2pool.tar.gz
|
||||
./p2pool --params-file params.conf # 配置模板见仓库 conf/params.conf.example
|
||||
```
|
||||
|
||||
详细配置说明请查看:[README-params.md](README-params.md)
|
||||
## 构建与发布
|
||||
|
||||
### 本地构建
|
||||
CI 定义于 [.gitea/workflows/ci.yaml](.gitea/workflows/ci.yaml):
|
||||
|
||||
- **push 到 `main`/`develop`**:矩阵 `arch=[amd64,arm64]`,在原生 runner 上用 Docker(musl 纯静态)编译为 tar.gz 并打 `.deb`。
|
||||
- **打 tag**:产物上传到 Generic / Debian 包仓库并创建 Release。
|
||||
|
||||
本地构建:
|
||||
|
||||
```bash
|
||||
# Alpine 构建(推荐,体积更小)
|
||||
docker buildx build --pull \
|
||||
--platform linux/amd64 \
|
||||
--build-arg P2POOL_VERSION=v4.13 \
|
||||
# 编译某架构二进制(输出到 ./output/linux_<arch>/p2pool)
|
||||
docker buildx build --platform linux/amd64 \
|
||||
--build-arg P2POOL_VERSION=v4.17 \
|
||||
--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.13 \
|
||||
--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.17 p2pool-amd64-linux-static-4.17.tar.gz
|
||||
```
|
||||
|
||||
## 📚 文档
|
||||
## 版本号约定
|
||||
|
||||
完整的项目文档位于 [llmdoc/](llmdoc/) 目录:
|
||||
- **上游源码 git tag** 带 `v`(如 `v4.17`),CI 用 `P2POOL_VERSION=v${PACKAGE_VERSION}` 检出。
|
||||
- **包版本**(tar.gz / deb / registry 路径)一律用数字(如 `4.17`),符合 Debian 版本规范。
|
||||
|
||||
- **[项目概述](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)** - 安装和配置
|
||||
发版只需改 ci.yaml 的 `PACKAGE_VERSION`。
|
||||
|
||||
## 🏗️ 构建系统
|
||||
## 目录结构
|
||||
|
||||
### 支持的架构和平台
|
||||
|
||||
| 架构 | Alpine | Ubuntu | Debian 包 |
|
||||
|------|--------|--------|-----------|
|
||||
| amd64 | ✅ | ✅ | ✅ |
|
||||
| arm64 | ✅ | ✅ | ✅ |
|
||||
|
||||
### 构建产物
|
||||
|
||||
- **二进制包** (`tar.gz`) - 适用于所有 Linux 发行版
|
||||
- **Debian 包** (`.deb`) - 适用于 Debian/Ubuntu 系统
|
||||
|
||||
## 🔧 配置管理
|
||||
|
||||
本项目使用配置文件管理 P2Pool 设置,提供以下优势:
|
||||
|
||||
- ✅ **升级安全** - 配置文件在包升级时不会被覆盖
|
||||
- ✅ **集中管理** - 所有设置在一个位置
|
||||
- ✅ **易于维护** - 支持注释和版本控制
|
||||
|
||||
配置文件模板:[params.conf.example](params.conf.example)
|
||||
|
||||
## 📦 发布流程
|
||||
|
||||
项目使用 Gitea Actions 实现自动化 CI/CD:
|
||||
|
||||
1. **代码推送** → 触发构建(main/develop 分支)
|
||||
2. **创建标签** → 触发完整发布流程
|
||||
3. **自动构建** → 4 种组合(2 架构 × 2 发行版)
|
||||
4. **自动发布** → 上传到包注册中心
|
||||
5. **创建 Release** → 附带下载链接和说明
|
||||
|
||||
|
||||
## 🔐 安全性
|
||||
|
||||
- ✅ 禁用上游合并挖矿捐赠
|
||||
- ✅ 使用专用用户运行服务
|
||||
- ✅ Systemd 安全加固
|
||||
- ✅ 最小权限原则
|
||||
- ✅ 安全的文件权限设置
|
||||
|
||||
## 📄 许可证
|
||||
|
||||
本项目为上游 [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)
|
||||
|
||||
---
|
||||
|
||||
**注意**: 本仓库不包含 p2pool 源代码,仅提供构建和打包基础设施。
|
||||
```
|
||||
.gitea/workflows/ CI 流水线
|
||||
docker/ Dockerfile(musl 纯静态,从上游官方源码编译)
|
||||
debian/ .deb 打包:control 模板、维护脚本、systemd 服务
|
||||
conf/ params.conf.example 默认配置模板
|
||||
```
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
# P2Pool Configuration File Example
|
||||
# Copy this file to /etc/p2pool/params.conf and edit as needed
|
||||
# Compatible with: p2pool v4.17+
|
||||
|
||||
# =============================================================================
|
||||
# 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)
|
||||
# v4.14+: ZMQ connections now support IPv6 addresses
|
||||
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
|
||||
|
||||
# HAProxy PROXY Protocol v2 for P2P connections (v4.14+)
|
||||
# Enable ONLY if p2pool's P2P port is behind a proxy that sends PROXY Protocol
|
||||
# v2 headers (e.g. HAProxy with "send-proxy-v2" directive).
|
||||
# When enabled, the real client IP is extracted from the PROXY header and used
|
||||
# for peer management, ban checks and logging — instead of the proxy's IP.
|
||||
# P2P traffic is typically low-volume and usually does NOT need load balancing;
|
||||
# leave commented out unless you have a specific reason to proxy P2P.
|
||||
# Leave commented to disable; uncomment to enable.
|
||||
# p2p-proxy-protocol = true
|
||||
|
||||
# =============================================================================
|
||||
# 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>
|
||||
# stratum = 0.0.0.0:3333
|
||||
|
||||
# HAProxy PROXY Protocol v2 for Stratum connections (v4.14+)
|
||||
# Enable ONLY if p2pool's Stratum port is behind a proxy that sends PROXY
|
||||
# Protocol v2 headers (e.g. HAProxy with "send-proxy-v2" directive).
|
||||
# When enabled, miners' real IP addresses are correctly extracted and shown
|
||||
# in the `workers` command output, and per-IP ban/rate-limiting works properly.
|
||||
# This is an open standard also supported by nginx, Traefik, AWS ELB, etc.;
|
||||
# it is NOT tied to HAProxy specifically.
|
||||
#
|
||||
# ⚠️ TLV extensions (send-proxy-v2-ssl, send-proxy-v2-ssl-cn,
|
||||
# unique-id-format, crc32c) are silently ignored — only the address block
|
||||
# is read. Do NOT use exact addr_len checks in custom builds (spec §2.2
|
||||
# allows senders to append TLV vectors, increasing addr_len beyond the
|
||||
# base 12 / 36 bytes).
|
||||
#
|
||||
# Leave commented to disable; uncomment to enable.
|
||||
# stratum-proxy-protocol = true
|
||||
|
||||
# =============================================================================
|
||||
# Merge Mining (Optional)
|
||||
# =============================================================================
|
||||
# Tari merge mining (this build includes gRPC, so tari:// is supported)
|
||||
# Format: tari://<tari_node_ip>:<port> <tari_wallet_address>
|
||||
# merge-mine = tari://127.0.0.1:18142 YOUR_TARI_WALLET_ADDRESS
|
||||
#
|
||||
# Generic JSON-RPC merge mining (other merge-mineable chains).
|
||||
# v4.16+: TLS supported — prefix the host with https:// (default port 443).
|
||||
# merge-mine = https://aux-node.example.com YOUR_AUX_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
|
||||
|
||||
# Disable logging destinations (v4.15+)
|
||||
# Leave commented unless you want to disable logging output.
|
||||
# disable-log is equivalent to no-console-log + no-log-file and saves ~8 MB RAM.
|
||||
# no-console-log = true
|
||||
# no-log-file = true
|
||||
# disable-log = true
|
||||
|
||||
# =============================================================================
|
||||
# Performance Tuning (Advanced)
|
||||
# =============================================================================
|
||||
# in-peers = 10
|
||||
# Maximum incoming localhost P2P connections (v4.17+)
|
||||
# in-peers-localhost = 10
|
||||
# out-peers = 10
|
||||
|
||||
# =============================================================================
|
||||
# Network Settings (Advanced)
|
||||
# =============================================================================
|
||||
# SOCKS5 proxy for outgoing connections
|
||||
# socks5 = 127.0.0.1:9050
|
||||
|
||||
# SOCKS5 proxy type (v4.14+, i2p value added in v4.15)
|
||||
# Controls how p2pool treats the SOCKS5 proxy configured above.
|
||||
# Accepted values:
|
||||
# auto - auto-detect by port number (9050 = Tor, 4447 = I2P; default)
|
||||
# plain - treat as a standard SOCKS5 proxy (no Tor/I2P-specific behavior)
|
||||
# tor - treat as a Tor SOCKS5 proxy (enables .onion peer handling)
|
||||
# i2p - treat as an I2P SOCKS5 proxy (enables .b32.i2p peer handling)
|
||||
# Only meaningful when `socks5` is set; ignored otherwise.
|
||||
# socks5-proxy-type = auto
|
||||
|
||||
# I2P support (v4.15+)
|
||||
# Requires an I2P SOCKS proxy, usually 127.0.0.1:4447 with i2pd.
|
||||
# Recommended for I2P-only P2P to avoid clearnet/DNS/UPnP leaks:
|
||||
# socks5 = 127.0.0.1:4447
|
||||
# socks5-proxy-type = i2p
|
||||
# no-dns = true
|
||||
# no-upnp = true
|
||||
# no-clearnet-p2p = true
|
||||
#
|
||||
# Broadcast your I2P hidden service .b32.i2p address to peers.
|
||||
# This address is linked to shares mined by your wallet; use a dedicated
|
||||
# I2P address for mining.
|
||||
# i2p-address = YOUR_I2P_ADDRESS.b32.i2p
|
||||
Vendored
+6
-2
@@ -4,7 +4,7 @@ set -e
|
||||
# 参数检查
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "Usage: $0 <ARCH> <VERSION> <TARGZ_FILE>"
|
||||
echo "Example: $0 amd64 v4.12 p2pool-amd64-ubuntu-v4.12.tar.gz"
|
||||
echo "Example: $0 amd64 4.17 p2pool-amd64-linux-static-4.17.tar.gz"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -45,12 +45,15 @@ PKG_DIR="${BUILD_DIR}/${PKG_NAME}_${DEB_VERSION}_${DEB_ARCH}"
|
||||
mkdir -p "${PKG_DIR}/DEBIAN"
|
||||
mkdir -p "${PKG_DIR}/opt/p2pool"
|
||||
mkdir -p "${PKG_DIR}/lib/systemd/system"
|
||||
mkdir -p "${PKG_DIR}/etc/p2pool"
|
||||
|
||||
# 解压二进制文件
|
||||
echo "📂 Extracting binaries..."
|
||||
tar -xzf "${TARGZ_FILE}" -C "${PKG_DIR}/opt/p2pool"
|
||||
|
||||
# 打入默认配置(conf/params.conf.example 为唯一配置源,postinst 据此生成 /etc/p2pool/params.conf)
|
||||
echo "📄 Bundling default config..."
|
||||
cp conf/params.conf.example "${PKG_DIR}/opt/p2pool/params.conf"
|
||||
|
||||
# 生成 control 文件
|
||||
echo "📝 Generating control file..."
|
||||
sed -e "s/{{VERSION}}/${DEB_VERSION}/" \
|
||||
@@ -72,6 +75,7 @@ cp debian/p2pool.service "${PKG_DIR}/lib/systemd/system/"
|
||||
|
||||
# 设置权限
|
||||
chmod 755 "${PKG_DIR}/opt/p2pool/p2pool"
|
||||
chmod 644 "${PKG_DIR}/opt/p2pool/params.conf"
|
||||
chmod 644 "${PKG_DIR}/lib/systemd/system/p2pool.service"
|
||||
|
||||
# 构建 deb 包
|
||||
|
||||
Vendored
-1
@@ -3,7 +3,6 @@ Version: {{VERSION}}
|
||||
Section: net
|
||||
Priority: optional
|
||||
Architecture: {{ARCH}}
|
||||
Depends: libc6, libuv1, libzmq5, libcurl4
|
||||
Maintainer: P2Pool Team <noreply@example.com>
|
||||
Homepage: https://github.com/SChernykh/p2pool
|
||||
Description: Decentralized pool for Monero mining
|
||||
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ Type=simple
|
||||
User=p2pool
|
||||
Group=p2pool
|
||||
WorkingDirectory=/var/lib/p2pool
|
||||
ExecStart=/opt/p2pool/p2pool --params-file /var/lib/p2pool/params.conf
|
||||
ExecStart=/opt/p2pool/p2pool --params-file /etc/p2pool/params.conf
|
||||
Restart=on-failure
|
||||
RestartSec=10s
|
||||
StandardOutput=journal
|
||||
|
||||
Vendored
+39
-84
@@ -12,78 +12,48 @@ if ! getent passwd p2pool >/dev/null; then
|
||||
--gecos "P2Pool Service" p2pool
|
||||
fi
|
||||
|
||||
# Create data directory
|
||||
mkdir -p /var/lib/p2pool/data-api
|
||||
chown -R p2pool:p2pool /var/lib/p2pool
|
||||
chmod -R 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 << 'CONF'
|
||||
# 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
|
||||
|
||||
# Use SSL for RPC connection
|
||||
# rpc-ssl = true
|
||||
|
||||
# RPC credentials (if applicable)
|
||||
# rpc-login = username:password
|
||||
|
||||
# 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:18142 TARI_WALLET_ADDRESS
|
||||
|
||||
# Stratum server (for miners to connect)
|
||||
# stratum = 0.0.0.0:3333
|
||||
CONF
|
||||
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
|
||||
chmod 750 /var/log/p2pool
|
||||
|
||||
# Set binary permissions
|
||||
chown root:root /opt/p2pool/p2pool
|
||||
# Create data directory(非递归设权限,避免升级时遍历庞大数据目录)
|
||||
mkdir -p /var/lib/p2pool/data-api
|
||||
chown p2pool:p2pool /var/lib/p2pool /var/lib/p2pool/data-api
|
||||
chmod 750 /var/lib/p2pool /var/lib/p2pool/data-api
|
||||
|
||||
# Create config directory
|
||||
mkdir -p /etc/p2pool
|
||||
|
||||
# 兼容旧版本:配置文件曾位于 /var/lib/p2pool/params.conf,迁移到 /etc/p2pool/params.conf
|
||||
if [ ! -f /etc/p2pool/params.conf ] && [ -f /var/lib/p2pool/params.conf ]; then
|
||||
echo "Migrating existing config from /var/lib/p2pool to /etc/p2pool..."
|
||||
cp /var/lib/p2pool/params.conf /etc/p2pool/params.conf
|
||||
fi
|
||||
|
||||
# 首次安装:从包内默认配置生成(源:conf/params.conf.example)。升级不覆盖已有配置
|
||||
if [ ! -f /etc/p2pool/params.conf ]; then
|
||||
cp /opt/p2pool/params.conf /etc/p2pool/params.conf
|
||||
fi
|
||||
|
||||
chown p2pool:p2pool /etc/p2pool/params.conf
|
||||
chmod 640 /etc/p2pool/params.conf
|
||||
|
||||
# Set permissions:/opt 目录与二进制 755,数据文件 644(对齐 xxxig / xxxig-proxy / mond)
|
||||
chown -R root:root /opt/p2pool
|
||||
find /opt/p2pool -type d -exec chmod 755 {} +
|
||||
find /opt/p2pool -type f -exec chmod 644 {} +
|
||||
chmod 755 /opt/p2pool/p2pool
|
||||
|
||||
# Reload systemd and handle service restart on upgrade
|
||||
# Reload systemd
|
||||
if [ -d /run/systemd/system ]; then
|
||||
systemctl daemon-reload
|
||||
|
||||
# On upgrade: restart service if it was enabled
|
||||
if [ "$1" = "configure" ] && [ -n "$2" ]; then
|
||||
# $2 is the previously installed version (only set on upgrade)
|
||||
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
|
||||
echo "Restarting p2pool service after upgrade..."
|
||||
systemctl start p2pool.service || true
|
||||
fi
|
||||
fi
|
||||
# 升级时重启正在运行的服务以加载新二进制;try-restart 不会启动未运行的服务,
|
||||
# 故首次安装仍保持"不自动启动"语义
|
||||
systemctl try-restart p2pool.service 2>/dev/null || true
|
||||
|
||||
# Note: On fresh install, service is NOT auto-enabled or auto-started
|
||||
# Users should manually enable the service:
|
||||
# systemctl enable p2pool.service
|
||||
# systemctl start p2pool.service
|
||||
fi
|
||||
@@ -91,31 +61,16 @@ fi
|
||||
echo ""
|
||||
echo "✅ P2Pool installed successfully!"
|
||||
echo ""
|
||||
echo "📋 Before starting P2Pool, you MUST configure your settings:"
|
||||
echo ""
|
||||
echo "1. Edit the configuration file:"
|
||||
echo " sudo nano /var/lib/p2pool/params.conf"
|
||||
echo ""
|
||||
echo " Set your Monero wallet address and adjust other settings as needed."
|
||||
echo ""
|
||||
echo "2. Start P2Pool:"
|
||||
echo " sudo systemctl enable p2pool.service"
|
||||
echo " sudo systemctl start p2pool.service"
|
||||
echo ""
|
||||
echo "3. Check status:"
|
||||
echo " sudo systemctl status p2pool.service"
|
||||
echo " sudo journalctl -u p2pool -f"
|
||||
echo ""
|
||||
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 " Config file: /etc/p2pool/params.conf"
|
||||
echo " Data directory: /var/lib/p2pool/data-api"
|
||||
echo " Log directory: /var/log/p2pool"
|
||||
echo " Binaries: /opt/p2pool/p2pool"
|
||||
echo " Systemd services: p2pool.service"
|
||||
echo ""
|
||||
echo "💡 Tip: Your params.conf will NOT be overwritten during package upgrades."
|
||||
echo ""
|
||||
echo "For help:"
|
||||
echo " /opt/p2pool/p2pool --help"
|
||||
echo "💡 Tip: Your config files will NOT be overwritten during package upgrades."
|
||||
echo " Before starting, set your Monero wallet in /etc/p2pool/params.conf, then:"
|
||||
echo " sudo systemctl enable --now p2pool.service"
|
||||
echo ""
|
||||
|
||||
exit 0
|
||||
|
||||
Vendored
+2
-1
@@ -12,9 +12,10 @@ case "$1" in
|
||||
delgroup --quiet p2pool || true
|
||||
fi
|
||||
|
||||
# Remove data directories (only on purge)
|
||||
# Remove data/config directories (only on purge)
|
||||
rm -rf /var/lib/p2pool
|
||||
rm -rf /var/log/p2pool
|
||||
rm -rf /etc/p2pool
|
||||
;;
|
||||
|
||||
remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
|
||||
|
||||
Vendored
+17
-32
@@ -1,33 +1,18 @@
|
||||
case "$1" in
|
||||
upgrade)
|
||||
# Stop service only during upgrade, keep enabled state
|
||||
if [ -d /run/systemd/system ]; then
|
||||
if systemctl is-active --quiet p2pool.service; then
|
||||
echo "Stopping p2pool service for upgrade..."
|
||||
systemctl stop p2pool.service
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
remove|deconfigure)
|
||||
# Stop and disable service during removal
|
||||
if [ -d /run/systemd/system ]; then
|
||||
if systemctl is-active --quiet p2pool.service; then
|
||||
echo "Stopping p2pool service..."
|
||||
systemctl stop p2pool.service
|
||||
fi
|
||||
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
|
||||
echo "Disabling p2pool service..."
|
||||
systemctl disable p2pool.service
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
failed-upgrade)
|
||||
# Do nothing on failed upgrade
|
||||
;;
|
||||
*)
|
||||
echo "prerm called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
exit 0
|
||||
# 仅在卸载(remove)时停用服务;升级(upgrade)时保持运行,
|
||||
# 由 postinst 的 try-restart 重启以加载新二进制
|
||||
if [ "$1" = "remove" ] && [ -d /run/systemd/system ]; then
|
||||
if systemctl is-active --quiet p2pool.service; then
|
||||
echo "Stopping p2pool service..."
|
||||
systemctl stop p2pool.service
|
||||
fi
|
||||
|
||||
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
|
||||
echo "Disabling p2pool service..."
|
||||
systemctl disable p2pool.service
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
# p2pool musl 纯静态构建(external 静态库参照上游官方 c-cpp.yml 的 Alpine static 流程)
|
||||
# Alpine + 自编 external 静态库(curl/libuv/libzmq) + 静态 grpc 栈(WITH_GRPC=ON,Tari 合并挖矿) + -DSTATIC_BINARY=ON
|
||||
# 产物 fully-static(ldd: not a dynamic executable),glibc/musl 任意发行版直接运行。
|
||||
# 为何 musl:musl getaddrinfo 自包含,全静态可跨发行版;glibc 静态会因 NSS dlopen 失败。
|
||||
FROM alpine:3.21 AS build
|
||||
ARG P2POOL_VERSION
|
||||
ARG TARGETARCH
|
||||
RUN apk add --no-cache git cmake gcc g++ make linux-headers perl
|
||||
|
||||
RUN git clone https://github.com/SChernykh/p2pool /src/p2pool
|
||||
WORKDIR /src/p2pool
|
||||
# 拉 8 个常规子模块 + grpc 及其 6 个必需 third_party(abseil/boringssl/cares/protobuf/re2/zlib)。
|
||||
# WITH_GRPC=ON 需完整 grpc 栈静态编译以支持 Tari 合并挖矿;其余 9 个 grpc 子模块
|
||||
# (benchmark/googletest/envoy/googleapis/xds 等测试或 xDS 依赖,已 GRPC_NO_XDS) 跳过省体积/时间。
|
||||
RUN git checkout ${P2POOL_VERSION} && \
|
||||
git submodule update --init --recursive \
|
||||
external/src/RandomX external/src/rapidjson external/src/cppzmq \
|
||||
external/src/libuv external/src/libzmq external/src/robin-hood-hashing \
|
||||
external/src/curl external/src/miniupnp && \
|
||||
git submodule update --init external/src/grpc && \
|
||||
git -C external/src/grpc submodule update --init --recursive \
|
||||
third_party/abseil-cpp third_party/boringssl-with-bazel \
|
||||
third_party/cares/cares third_party/protobuf third_party/re2 third_party/zlib
|
||||
|
||||
# external libcurl:HTTP + p2pool boringssl 集成(保留 rpc-ssl 连 HTTPS monerod)。
|
||||
# 完整照搬官方 c-cpp.yml 的 curl flags:P2POOL_BORINGSSL=ON 是上游给 curl 打的独立
|
||||
# boringssl TLS 后端补丁(不走 curl 标准 CURL_ENABLE_SSL 路径,故二者共存且仍支持 --rpc-ssl)。
|
||||
# 一整套 CURL_DISABLE_*(尤其 SRP/AWS/*_AUTH) 用于跳过会引用 OpenSSL::SSL imported target 的
|
||||
# curl_openssl_check_exists 符号检测——新版 cmake 在 try_compile 阶段校验该 target 必失败,少一个都会触发。
|
||||
RUN cd external/src/curl && cmake . -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCURL_DROP_UNUSED=ON -DCURL_DISABLE_TYPECHECK=ON \
|
||||
-DCURL_DISABLE_OPENSSL_AUTO_LOAD_CONFIG=ON -DCURL_DISABLE_SHA512_256=ON \
|
||||
-DPICKY_COMPILER=OFF -DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF \
|
||||
-DCURL_DISABLE_INSTALL=ON -DCURL_ENABLE_EXPORT_TARGET=OFF \
|
||||
-DCURL_DISABLE_HEADERS_API=ON -DCURL_DISABLE_BINDLOCAL=ON \
|
||||
-DBUILD_LIBCURL_DOCS=OFF -DBUILD_MISC_DOCS=OFF -DENABLE_CURL_MANUAL=OFF \
|
||||
-DCURL_ZLIB=OFF -DCURL_BROTLI=OFF -DCURL_ZSTD=OFF \
|
||||
-DCURL_DISABLE_ALTSVC=ON -DCURL_DISABLE_COOKIES=ON -DCURL_DISABLE_DOH=ON \
|
||||
-DCURL_DISABLE_GETOPTIONS=ON -DCURL_DISABLE_HSTS=ON \
|
||||
-DCURL_DISABLE_LIBCURL_OPTION=ON -DCURL_DISABLE_MIME=ON \
|
||||
-DCURL_DISABLE_NETRC=ON -DCURL_DISABLE_NTLM=ON -DCURL_DISABLE_PARSEDATE=ON \
|
||||
-DCURL_DISABLE_PROGRESS_METER=ON -DCURL_DISABLE_SHUFFLE_DNS=ON \
|
||||
-DCURL_DISABLE_VERBOSE_STRINGS=ON -DHTTP_ONLY=ON -DCURL_ENABLE_SSL=OFF \
|
||||
-DUSE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF -DCURL_USE_LIBSSH2=OFF \
|
||||
-DENABLE_UNIX_SOCKETS=OFF -DBUILD_TESTING=OFF -DUSE_NGHTTP2=OFF \
|
||||
-DBUILD_EXAMPLES=OFF -DP2POOL_BORINGSSL=ON -DCURL_DISABLE_SRP=ON \
|
||||
-DCURL_DISABLE_AWS=ON -DCURL_DISABLE_BASIC_AUTH=ON \
|
||||
-DCURL_DISABLE_BEARER_AUTH=ON -DCURL_DISABLE_KERBEROS_AUTH=ON \
|
||||
-DCURL_DISABLE_NEGOTIATE_AUTH=ON \
|
||||
-DOPENSSL_INCLUDE_DIR=../grpc/third_party/boringssl-with-bazel/include && \
|
||||
make -j"$(nproc)"
|
||||
|
||||
# external libuv 静态
|
||||
RUN cd external/src/libuv && mkdir build && cd build && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF -DLIBUV_BUILD_SHARED=OFF && \
|
||||
make -j"$(nproc)"
|
||||
|
||||
# external libzmq 静态
|
||||
RUN cd external/src/libzmq && mkdir build && cd build && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||
-DWITH_LIBSODIUM=OFF -DWITH_LIBBSD=OFF -DBUILD_TESTS=OFF -DWITH_DOCS=OFF \
|
||||
-DENABLE_DRAFTS=OFF -DBUILD_SHARED=OFF && \
|
||||
make -j"$(nproc)"
|
||||
|
||||
# p2pool 主体:纯静态(STATIC_BINARY) + 启用 grpc(Tari 合并挖矿) + 禁合并挖矿捐赠(gitea-p2pool 定制)
|
||||
RUN if [ "$TARGETARCH" = "arm64" ]; then ARCH_ID=aarch64; else ARCH_ID=x86_64; fi && \
|
||||
mkdir build && cd build && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||
-DSTATIC_BINARY=ON -DWITH_GRPC=ON -DWITH_MERGE_MINING_DONATION=OFF \
|
||||
-DARCH_ID="$ARCH_ID" \
|
||||
-DCMAKE_C_FLAGS='-Wl,-s -Wl,--gc-sections' \
|
||||
-DCMAKE_CXX_FLAGS='-Wl,-s -Wl,--gc-sections' && \
|
||||
make -j"$(nproc)" p2pool && cp p2pool /p2pool
|
||||
|
||||
FROM scratch
|
||||
ARG TARGETARCH
|
||||
COPY --from=build /p2pool /linux_${TARGETARCH}/p2pool
|
||||
@@ -1,46 +0,0 @@
|
||||
FROM alpine:3.21 AS base
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
RUN apk update && apk add --no-cache \
|
||||
git \
|
||||
cmake \
|
||||
gcc \
|
||||
g++ \
|
||||
make \
|
||||
linux-headers \
|
||||
libuv-dev \
|
||||
zeromq-dev \
|
||||
curl-dev
|
||||
|
||||
FROM base AS build
|
||||
|
||||
ARG P2POOL_VERSION
|
||||
ARG TARGETARCH
|
||||
ARG BUILDPLATFORM
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
RUN git clone --recursive https://github.com/SChernykh/p2pool /src/p2pool
|
||||
|
||||
WORKDIR /src/p2pool
|
||||
|
||||
RUN git checkout ${P2POOL_VERSION}
|
||||
|
||||
# Determine parallel jobs based on cross-compilation and architecture
|
||||
RUN mkdir build && cd build && \
|
||||
if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
||||
MAKE_JOBS="-j2"; \
|
||||
elif [ "$TARGETARCH" = "amd64" ]; then \
|
||||
MAKE_JOBS="-j$(($(nproc) / 2))"; \
|
||||
else \
|
||||
MAKE_JOBS="-j$(nproc)"; \
|
||||
fi && \
|
||||
echo "Building with parallel jobs: $MAKE_JOBS (arch: $TARGETARCH, cross-compile: $([ "$BUILDPLATFORM" != "$TARGETPLATFORM" ] && echo yes || echo no))" && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_MERGE_MINING_DONATION=OFF && \
|
||||
make $MAKE_JOBS
|
||||
|
||||
FROM scratch
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
COPY --from=build /src/p2pool/build/p2pool /linux_${TARGETARCH}/p2pool
|
||||
@@ -1,46 +0,0 @@
|
||||
FROM ubuntu:24.04 AS base
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
cmake \
|
||||
gcc \
|
||||
g++ \
|
||||
make \
|
||||
libuv1-dev \
|
||||
libzmq3-dev \
|
||||
libcurl4-openssl-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
FROM base AS build
|
||||
|
||||
ARG P2POOL_VERSION
|
||||
ARG TARGETARCH
|
||||
ARG BUILDPLATFORM
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
RUN git clone --recursive https://github.com/SChernykh/p2pool /src/p2pool
|
||||
|
||||
WORKDIR /src/p2pool
|
||||
|
||||
RUN git checkout ${P2POOL_VERSION}
|
||||
|
||||
# Determine parallel jobs based on cross-compilation and architecture
|
||||
RUN mkdir build && cd build && \
|
||||
if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
|
||||
MAKE_JOBS="-j2"; \
|
||||
elif [ "$TARGETARCH" = "amd64" ]; then \
|
||||
MAKE_JOBS="-j$(($(nproc) / 2))"; \
|
||||
else \
|
||||
MAKE_JOBS="-j$(nproc)"; \
|
||||
fi && \
|
||||
echo "Building with parallel jobs: $MAKE_JOBS (arch: $TARGETARCH, cross-compile: $([ "$BUILDPLATFORM" != "$TARGETPLATFORM" ] && echo yes || echo no))" && \
|
||||
cmake .. -DCMAKE_BUILD_TYPE=Release -DWITH_MERGE_MINING_DONATION=OFF && \
|
||||
make $MAKE_JOBS
|
||||
|
||||
FROM scratch
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
COPY --from=build /src/p2pool/build/p2pool /linux_${TARGETARCH}/p2pool
|
||||
@@ -1,83 +0,0 @@
|
||||
# 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 虚拟化
|
||||
@@ -1,45 +0,0 @@
|
||||
# Debian 打包架构
|
||||
|
||||
## 1. 身份
|
||||
|
||||
- **目的**:为 p2pool 构建跨架构的 Debian 软件包
|
||||
- **关键功能**:多架构支持、自动化构建和发布
|
||||
|
||||
## 2. 核心组件
|
||||
|
||||
关键文件:
|
||||
- `.gitea/workflows/ci.yaml`:CI/CD 流程
|
||||
- `debian/build-deb.sh`:Debian 打包脚本
|
||||
- `debian/control`:软件包元数据
|
||||
- `debian/postinst`:安装后脚本
|
||||
- `debian/postrm`:卸载后脚本
|
||||
|
||||
## 3. 构建流程
|
||||
|
||||
1. **架构选择**:
|
||||
- `amd64`: 64位 x86 架构
|
||||
- `arm64`: ARM 64位架构
|
||||
|
||||
2. **发行版目标**:
|
||||
- `stable`:统一的稳定发行版仓库
|
||||
|
||||
3. **Package Registry**:
|
||||
- Generic Package Registry:存储 `.tar.gz`
|
||||
- Debian Package Registry:存储 `.deb`
|
||||
|
||||
## 4. 配置管理
|
||||
|
||||
- 配置文件:`/var/lib/p2pool/params.conf`
|
||||
- 安全原则:
|
||||
- 配置与二进制包分离
|
||||
- 升级时保留用户配置
|
||||
- 最小权限原则
|
||||
|
||||
## 5. 发布策略
|
||||
|
||||
- 自动化版本发布
|
||||
- 标签触发(`refs/tags/*`)
|
||||
- 多渠道发布:
|
||||
1. Generic Package Registry
|
||||
2. Debian Package Registry
|
||||
3. GitHub/Gitea Releases
|
||||
@@ -1,93 +0,0 @@
|
||||
# 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` 参数
|
||||
- 编译过程禁用合并挖矿捐赠功能
|
||||
@@ -1,135 +0,0 @@
|
||||
# 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 stable 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
|
||||
```
|
||||
@@ -1,88 +0,0 @@
|
||||
# 本地构建指南
|
||||
|
||||
## 准备工作
|
||||
|
||||
### 系统依赖
|
||||
- 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 镜像和依赖更新
|
||||
- 对于大型项目,考虑使用构建缓存
|
||||
@@ -1,13 +0,0 @@
|
||||
# p2pool 文档系统
|
||||
|
||||
## 概述 (Overview)
|
||||
- [CI 工作流程](/llmdoc/overview/ci-workflow.md)
|
||||
|
||||
## 指南 (Guides)
|
||||
- [Debian 包安装](/llmdoc/guides/debian-package.md)
|
||||
|
||||
## 架构 (Architecture)
|
||||
- [Debian 打包架构](/llmdoc/architecture/debian-packaging.md)
|
||||
|
||||
## 参考 (Reference)
|
||||
(暂无)
|
||||
@@ -1,24 +0,0 @@
|
||||
# CI 工作流程概述
|
||||
|
||||
## 1. 身份
|
||||
|
||||
- **目的**:自动化构建、测试和发布 p2pool 软件包
|
||||
- **关键功能**:支持多架构、多发行版的软件包构建和发布
|
||||
|
||||
## 2. 高层描述
|
||||
|
||||
CI 工作流程通过 Gitea 工作流实现自动化构建和发布:
|
||||
|
||||
- 支持架构:`amd64`、`arm64`
|
||||
- 支持发行版:`ubuntu`、`alpine`
|
||||
- 发布目标:
|
||||
1. Generic Package Registry
|
||||
2. Debian Package Registry (stable)
|
||||
3. GitHub/Gitea Releases
|
||||
|
||||
## 3. 关键文件
|
||||
|
||||
- `.gitea/workflows/ci.yaml`:主要工作流配置
|
||||
- `debian/build-deb.sh`:Debian 打包脚本
|
||||
- `docker/Dockerfile.ubuntu`:Ubuntu 构建镜像
|
||||
- `docker/Dockerfile.alpine`:Alpine 构建镜像
|
||||
@@ -1,45 +0,0 @@
|
||||
# 项目概述: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
|
||||
- 需要配置钱包地址才能运行服务
|
||||
@@ -1,59 +0,0 @@
|
||||
# 编码规范
|
||||
|
||||
## 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)等
|
||||
@@ -1,79 +0,0 @@
|
||||
# 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
|
||||
```
|
||||
@@ -1,84 +0,0 @@
|
||||
# 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