From 3255f2be8c049086efcdb7259d2c15352bab94d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=96=8C?= <259278618@qq.com> Date: Mon, 22 Jun 2026 14:10:29 +0800 Subject: [PATCH] =?UTF-8?q?docker=E5=AE=89=E8=A3=85FFmpeg=20+=20Python3=20?= =?UTF-8?q?+=20PySceneDetect=20+=20Node.js=20+=20HyperFrames?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 31 +++++++++++++------------------ main.go | 2 +- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index bb99744..3be80a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,37 +22,32 @@ RUN go build -ldflags="-s -w" -o main ./main.go # 阶段2: 运行时(预装 FFmpeg + Python3 + PySceneDetect + Node.js + HyperFrames) FROM alpine:3.19 -# 启用 community 仓库(nodejs/npm 在其中) -RUN echo "https://dl-cdn.alpinelinux.org/alpine/v3.19/community" >> /etc/apk/repositories \ - && apk add --no-cache \ - ca-certificates \ - tzdata \ - ffmpeg \ - python3 \ - py3-pip \ - nodejs \ - npm \ - gcc \ - musl-dev \ - python3-dev \ - linux-headers +# nodejs/npm 在 community 仓库,需启用 +# 使用阿里云镜像加速 +RUN sed -i 's|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g' /etc/apk/repositories \ + && echo "https://mirrors.aliyun.com/alpine/v3.19/community" >> /etc/apk/repositories \ + && apk add --no-cache ca-certificates tzdata ffmpeg python3 py3-pip nodejs npm \ + gcc musl-dev python3-dev linux-headers ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # 预装 PySceneDetect(opencv-headless 无需 GUI 依赖) -RUN pip3 install --break-system-packages scenedetect[opencv-headless,ffmpeg] +# 使用阿里云 PyPI 镜像加速 +RUN pip3 install --break-system-packages -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com scenedetect[opencv-headless,ffmpeg] + +# 验证 PySceneDetect 安装 +RUN python3 -c "import scenedetect; print(f'scenedetect {scenedetect.__version__} installed')" # 预装 HyperFrames(全局安装) -RUN npm install -g hyperframes +# 使用 npmmirror 镜像加速 +RUN npm install -g hyperframes --registry=https://registry.npmmirror.com/ WORKDIR /app # 复制二进制和运行时必需的文件 COPY --from=builder /build/main . COPY --from=builder /build/config.yml . -COPY --from=builder /build/scripts ./scripts - EXPOSE 3010 CMD ["./main"] diff --git a/main.go b/main.go index a687fc0..7a03a94 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( "gitea.redpowerfuture.com/red-future/common/http" "gitea.redpowerfuture.com/red-future/common/jaeger" - _ "media/service/setup" + //_ "media/service/setup" _ "github.com/gogf/gf/contrib/drivers/pgsql/v2" )