mirror of
https://github.com/lkddi/dell-fans-controller-docker.git
synced 2026-04-03 09:55:11 +08:00
添加GitHub Actions自动构建Docker镜像工作流
- 创建了自动构建和推送Docker镜像的GitHub Actions工作流 - 支持多架构构建 (linux/amd64, linux/arm64) - 自动推送到Docker Hub和阿里云容器镜像服务 - 更新Dockerfile以优化构建过程 - 更新README.md包含Docker镜像信息
This commit is contained in:
58
.github/workflows/docker-build.yml
vendored
Normal file
58
.github/workflows/docker-build.yml
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to Alibaba Cloud Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: registry.cn-huhehaote.aliyuncs.com
|
||||
username: ${{ secrets.ALIBABA_USERNAME }}
|
||||
password: ${{ secrets.ALIBABA_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
joestar817/dell-fans-controller-docker
|
||||
registry.cn-huhehaote.aliyuncs.com/lkddi_image/dell-fans-controller-docker
|
||||
tags: |
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=sha,prefix={{branch}}-
|
||||
latest
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
21
Dockerfile
21
Dockerfile
@@ -1,19 +1,26 @@
|
||||
FROM ubuntu:22.04
|
||||
LABEL maintainer="joestar817@foxmail.com"
|
||||
|
||||
|
||||
# 安装依赖并设置时区
|
||||
RUN apt update && apt install -y \
|
||||
ipmitool \
|
||||
python3 \
|
||||
python3-pip && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
python3-pip \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo 'Asia/Shanghai' > /etc/timezone
|
||||
|
||||
# 复制应用文件
|
||||
COPY . /dell-fans-controller-docker
|
||||
WORKDIR /dell-fans-controller-docker
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
RUN echo 'Asia/Shanghai' >/etc/timezone
|
||||
# 如果有requirements.txt则安装Python依赖
|
||||
# COPY requirements.txt .
|
||||
# RUN pip3 install --no-cache-dir -r requirements.txt
|
||||
|
||||
CMD ["python3","start.py"]
|
||||
# 暴露可能需要的端口(虽然这个应用不需要)
|
||||
# EXPOSE 80
|
||||
|
||||
# 设置启动命令
|
||||
CMD ["python3", "start.py"]
|
||||
|
||||
|
||||
@@ -28,6 +28,15 @@ docker run -d --name=dell-fans-controller-docker -e HOST=10.10.11.11 -e USERNAM
|
||||
|
||||
脚本首先通过ipmitool来获取 **进出口温度和CPU核心温度**,再通过其中的最大值来判断调整服务器的风扇转速
|
||||
|
||||
### Docker 镜像构建
|
||||
|
||||
本项目通过 GitHub Actions 自动构建 Docker 镜像,并推送到 Docker Hub 和阿里云容器镜像服务。
|
||||
|
||||
- Docker Hub: `joestar817/dell-fans-controller-docker:latest`
|
||||
- 阿里云: `registry.cn-huhehaote.aliyuncs.com/lkddi_image/dell-fans-controller-docker:latest`
|
||||
|
||||
镜像支持多架构 (linux/amd64, linux/arm64)
|
||||
|
||||
运行间隔为每60秒运行一次
|
||||
|
||||
| 温度(℃) | 风扇转速(%) |
|
||||
|
||||
Reference in New Issue
Block a user