Files
p2pool/llmdoc/architecture/docker-architecture.md
Wang Defa 9ff0daa938
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 和配置指南
- 提供完整的配置模板示例

配置文件优势:升级安全、集中管理、易于维护
2025-12-19 09:20:33 +08:00

93 lines
3.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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` 参数
- 编译过程禁用合并挖矿捐赠功能