发布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

View File

@@ -31,6 +31,21 @@ Windows GPU版本v1.1.0GPU
> 仅供具有Nvidia显卡的用户使用(AMD的显卡不行)
**Docker版本**
```shell
# Nvidia 10 20 30系显卡
docker run -it --rm --gpus all eritpchy/video-subtitle-remover:1.1.1-cuda11.8
# Nvidia 40系显卡
docker run -it --rm --gpus all eritpchy/video-subtitle-remover:1.1.1-cuda12.6
# Nvidia 50系显卡
docker run -it --rm --gpus all eritpchy/video-subtitle-remover:1.1.1-cuda12.8
# AMD / Intel 独显 集显
docker run -it --rm --gpus all eritpchy/video-subtitle-remover:1.1.1-directml
```
## 演示
- GUI版

30
docker/Dockerfile Normal file
View File

@@ -0,0 +1,30 @@
FROM python:3.12
RUN --mount=type=cache,target=/root/.cache,sharing=private \
apt update && \
apt install -y libgl1-mesa-glx && \
true
ADD . /vsr
ARG CUDA_VERSION=11.8
ARG USE_DIRECTML=0
# 如果是 CUDA 版本,执行 CUDA 特定设置
RUN --mount=type=cache,target=/root/.cache,sharing=private \
if [ "${USE_DIRECTML:-0}" != "1" ]; then \
pip install paddlepaddle==3.0 && \
pip install torch==2.7.0 torchvision==0.22.0 --index-url https://download.pytorch.org/whl/cu$(echo ${CUDA_VERSION} | tr -d '.') && \
pip install -r /vsr/requirements.txt; \
fi
# 如果是 DirectML 版本,执行 DirectML 特定设置
RUN --mount=type=cache,target=/root/.cache,sharing=private \
if [ "${USE_DIRECTML:-0}" = "1" ]; then \
pip install paddlepaddle==3.0 && \
pip install torch_directml==0.2.5.dev240914 && \
pip install -r /vsr/requirements.txt; \
fi
ENV LD_LIBRARY_PATH=/usr/local/lib/python3.12/site-packages/nvidia/cudnn/lib/
WORKDIR /vsr
CMD ["python", "/vsr/backend/main.py"]