Files
deploy/Dockerfile.media
T
2026-07-02 11:56:28 +08:00

65 lines
1.9 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.
# ========== 构建 Go 二进制 ==========
FROM golang:alpine AS builder
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
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 go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -ldflags="-s -w" -o main ./main.go
# ========== 运行时(FFmpeg + Python3 + PySceneDetect + Node.js + HyperFrames==========
FROM alpine:3.21
# 阿里云镜像 + community 仓库
RUN sed -i 's|dl-cdn.alpinelinux.org|mirrors.aliyun.com|g' /etc/apk/repositories \
&& echo "https://mirrors.aliyun.com/alpine/v3.21/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
# opencv
RUN apk add --no-cache py3-opencv
# PySceneDetect(虚拟环境隔离)
RUN python3 -m venv --system-site-packages /opt/venv \
&& /opt/venv/bin/pip install --no-deps -i https://mirrors.aliyun.com/pypi/simple/ \
--trusted-host mirrors.aliyun.com scenedetect \
&& /opt/venv/bin/pip install -i https://mirrors.aliyun.com/pypi/simple/ \
--trusted-host mirrors.aliyun.com click platformdirs tqdm
ENV PATH=/opt/venv/bin:$PATH
RUN python3 -c "import scenedetect; print(f'scenedetect {scenedetect.__version__} installed')"
# HyperFrames
RUN npm install -g hyperframes --ignore-scripts
# Chromium + 中文字体
RUN apk add --no-cache chromium font-noto-cjk fontconfig \
&& fc-cache -f
RUN npx hyperframes browser ensure
WORKDIR /app
COPY --from=builder /build/main .
COPY config.yml .
COPY scripts/ ./scripts/
EXPOSE 3010
CMD ["./main"]