发布docker镜像

This commit is contained in:
Jason
2025-04-24 21:43:02 +08:00
parent acdb150aa2
commit ea7e01e3aa
3 changed files with 132 additions and 0 deletions

87
.github/workflows/build-docker.yml vendored Normal file
View File

@@ -0,0 +1,87 @@
name: Docker Build and Push
on:
push:
branches:
- '**'
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- type: cuda
version: "11.8"
- type: cuda
version: "12.6"
- type: cuda
version: "12.8"
- type: directml
version: "latest"
steps:
- name: Show system
run: |
echo -e "Total CPU cores\t: $(nproc)"
cat /proc/cpuinfo | grep 'model name'
ulimit -a
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
swap-size-mb: 512
temp-reserve-mb: 1024
root-reserve-mb: 2048
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
- name: 检出代码
uses: actions/checkout@v4
- name: 读取 VERSION
id: version
run: |
VERSION=$(sed -n 's/^VERSION = "\(.*\)"/\1/p' backend/config.py)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
shell: bash
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 登录到 Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 提取元数据
id: meta
uses: docker/metadata-action@v4
with:
images: eritpchy/video-subtitle-remover
tags: |
type=raw,value=${{ env.VERSION }}-${{ matrix.type }}${{ matrix.type == 'cuda' && matrix.version || '' }}
- name: 构建并推送
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
build-args: |
${{ matrix.type == 'cuda' && format('CUDA_VERSION={0}', matrix.version) || '' }}
${{ matrix.type == 'directml' && 'USE_DIRECTML=1' || '' }}
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: eritpchy/video-subtitle-remover