55 lines
1.9 KiB
Docker
55 lines
1.9 KiB
Docker
# 压力测试工具镜像
|
||
#
|
||
# 用途:为 auto-check 提供预装压测工具与脚本的容器环境
|
||
# 优势:工具预装在镜像中,无需在目标机在线安装,环境一致性好
|
||
#
|
||
# 工作流程(固定分发模式,不依赖 registry):
|
||
# 1. auto-check 检测目标机器的 Docker 可用性
|
||
# 2. 目标机无镜像时,上传工程目录中导出的 tar(docker save)并 docker load
|
||
# 3. 启动容器执行测试(脚本已打包在镜像中,挂载 /sys 采集温度)
|
||
# 4. 收集测试结果并解析
|
||
#
|
||
# 构建与导出(推荐用脚本,自动时间戳 tag):
|
||
# cd docker/stress-test
|
||
# ./build.sh # 自动用当前时间戳打 tag
|
||
# ./build.sh 20260824-153045 # 或手动指定
|
||
# 脚本会同时:构建镜像(时间戳 tag) + 导出 tar + 同步 auto-check.yaml 配置
|
||
#
|
||
# 手动构建(如绕过脚本):
|
||
# cd docker/stress-test
|
||
# docker build -t stress-test:<时间戳> .
|
||
# docker save -o stress-test.tar stress-test:<时间戳>
|
||
# # 同步修改 ../../auto-check.yaml 的 docker_image
|
||
#
|
||
# 使用方式(在 auto-check.yaml 中配置):
|
||
# stress:
|
||
# docker_image: "stress-test:<时间戳>"
|
||
# docker_tar: "docker/stress-test/stress-test.tar"
|
||
|
||
FROM debian:12-slim
|
||
|
||
# UTF-8 locale:保证 sensors 输出带 ° 符号的温度格式(脚本正则依赖)
|
||
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||
|
||
# 清理缓存,减少镜像体积
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
stress-ng \
|
||
fio \
|
||
lm-sensors \
|
||
sysstat \
|
||
procps \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
# 验证工具安装
|
||
RUN stress-ng --version && fio --version && sensors --version
|
||
|
||
# 复制测试脚本到镜像中
|
||
COPY scripts/ /scripts/
|
||
|
||
# 设置脚本执行权限
|
||
RUN chmod +x /scripts/*.sh
|
||
|
||
WORKDIR /tmp
|
||
|
||
# 默认执行入口(由 auto-check 传入脚本参数)
|
||
ENTRYPOINT ["/bin/bash", "/scripts/run.sh"] |