Files
media/Dockerfile.scenedetect
T
2026-06-22 10:34:27 +08:00

48 lines
1.2 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 阶段1: 构建
FROM golang:alpine AS builder
RUN apk add --no-cache git ca-certificates tzdata
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
ENV CGO_ENABLED=0
ENV GOTOOLCHAIN=auto
WORKDIR /build
COPY . .
RUN go mod download && go mod tidy
RUN go build -ldflags="-s -w" -o main ./main.go
# 阶段2: 运行时(预装 FFmpeg + Python3 + PySceneDetect
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata ffmpeg python3 py3-pip \
gcc musl-dev python3-dev linux-headers
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
# 预装 PySceneDetectopencv-headless 无需 GUI 依赖)
# 使用 --break-system-packages 兼容 PEP 668 限制的 pip 版本
RUN pip3 install --break-system-packages scenedetect[opencv-headless,ffmpeg]
# 验证安装
RUN python3 -c "import scenedetect; print(f'scenedetect {scenedetect.__version__} installed')"
WORKDIR /app
# 复制二进制和运行时必需的文件
COPY --from=builder /build/main .
COPY --from=builder /build/config.yml .
COPY --from=builder /build/scripts ./scripts
EXPOSE 3010
CMD ["./main"]