Files
gb28181/Dockerfile_ai
T
2026-01-13 12:17:26 +08:00

84 lines
3.2 KiB
Plaintext
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.
# 使用 Debian Bullseye 作为基础镜像,因为 ZLMediaKit 需要 libssl1.1
FROM debian:trixie-slim
ENV TZ=Asia/Shanghai
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PYTHONPATH=/opt/media/bin/analysis
WORKDIR /opt/media/bin/
# 配置 apt 源使用阿里云镜像 (Trixie 使用新格式 sources.list.d/debian.sources)
RUN sed -i 's|http://deb.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || \
sed -i 's|http://deb.debian.org|http://mirrors.aliyun.com|g; \
s|http://security.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list 2>/dev/null || true
# 安装运行时依赖
# - python3/pip: AI 分析模块
# - libgl1/libglib2.0-0: OpenCV 需要
# 注意:Trixie 没有 libssl1.1,需要从 Bullseye 仓库安装
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
tzdata \
libstdc++6 \
libgcc-s1 \
libssl3 \
python3 \
python3-pip \
libgl1 \
libglib2.0-0 \
wget \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# 从 Debian Bullseye 下载并安装 libssl1.1ZLMediaKit 需要)
RUN wget -q http://mirrors.aliyun.com/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0+deb11u1_amd64.deb -O /tmp/libssl1.1_amd64.deb \
&& wget -q http://mirrors.aliyun.com/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0+deb11u1_arm64.deb -O /tmp/libssl1.1_arm64.deb \
&& dpkg -i /tmp/libssl1.1_$(dpkg --print-architecture).deb || true \
&& rm -f /tmp/libssl1.1_*.deb
# 配置 pip 使用阿里云镜像
RUN pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/ \
&& pip3 config set global.trusted-host mirrors.aliyun.com
# 安装 Python 依赖
# --break-system-packages: Debian Trixie 使用 PEP 668 保护系统 Python
# TFLite 支持:优先尝试 tflite-runtime,失败则用 ai-edge-litertGoogle 新包名)
COPY ./analysis/requirements.txt /tmp/requirements.txt
RUN pip3 install --no-cache-dir --break-system-packages -r /tmp/requirements.txt \
&& (pip3 install --no-cache-dir --break-system-packages \
-i https://pypi.org/simple/ tflite-runtime 2>/dev/null \
|| pip3 install --no-cache-dir --break-system-packages \
-i https://pypi.org/simple/ ai-edge-litert 2>/dev/null \
|| echo "TFLite runtime not available, will use ONNX only") \
&& rm /tmp/requirements.txt \
&& rm -rf /root/.cache/pip
# 从外部镜像复制 ZLMediaKit 和 ffmpeg
COPY --from=zlmediakit/zlmediakit:master /opt/media/bin /opt/media/bin
COPY --from=mwader/static-ffmpeg:6.1 /ffmpeg /usr/local/bin/ffmpeg
COPY --from=mwader/static-ffmpeg:6.1 /ffprobe /usr/local/bin/ffprobe
# 复制应用文件
# 使用 TARGETARCH 自动识别目标架构(amd64 或 arm64
ARG TARGETARCH
ADD ./build/linux_${TARGETARCH}/bin ./gowvp
ADD ./www ./www
ADD ./analysis ./analysis
RUN mkdir -p configs
RUN ln -sf /usr/local/bin/ffmpeg /usr/bin/ffmpeg && \
chmod +x /usr/local/bin/ffmpeg
RUN ln -sf /usr/local/bin/ffmpeg /opt/media/bin/ffmpeg
LABEL Name=gowvp \
Version=0.1.0 \
Maintainer="xx@golang.space" \
Description="gowvp & zlmediakit & ai (ONNX Runtime)"
EXPOSE 15123 1935 8080 554 50051 20000-20100/udp 20000-20100
CMD ["./gowvp"]