mirror of
https://github.com/gowvp/gb28181.git
synced 2026-04-22 23:17:19 +08:00
98 lines
3.4 KiB
Plaintext
98 lines
3.4 KiB
Plaintext
# ============================================
|
||
# 阶段 1: 构建 Python 依赖
|
||
# ============================================
|
||
FROM debian:trixie-slim AS python-builder
|
||
|
||
RUN sed -i 's|http://deb.debian.org|http://mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || true
|
||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
python3 \
|
||
python3-pip \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
RUN pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
|
||
pip3 config set global.trusted-host mirrors.aliyun.com
|
||
|
||
# 安装 Python 依赖到指定目录
|
||
# --no-deps: 避免安装 sympy 等可选依赖
|
||
# --only-binary :all:: 强制只安装预编译包
|
||
RUN pip3 install --no-cache-dir --break-system-packages --target=/python-packages --no-deps --only-binary :all: onnxruntime && \
|
||
pip3 install --no-cache-dir --break-system-packages --target=/python-packages --only-binary :all: \
|
||
grpcio \
|
||
opencv-python-headless \
|
||
numpy \
|
||
requests \
|
||
protobuf \
|
||
packaging \
|
||
coloredlogs \
|
||
flatbuffers
|
||
|
||
# ============================================
|
||
# 阶段 2: 最终运行镜像
|
||
# ============================================
|
||
FROM debian:trixie-slim
|
||
|
||
ENV TZ=Asia/Shanghai
|
||
ENV PYTHONDONTWRITEBYTECODE=1
|
||
ENV PYTHONUNBUFFERED=1
|
||
ENV PYTHONPATH=/opt/media/bin/analysis:/python-packages
|
||
|
||
WORKDIR /opt/media/bin/
|
||
|
||
# 配置 apt 源使用阿里云镜像加速
|
||
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
|
||
|
||
# 安装运行时依赖(极简版)
|
||
# 注意:opencv-python-headless 不需要 libgl1,移除可节省 ~160MB
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
ca-certificates \
|
||
tzdata \
|
||
libstdc++6 \
|
||
libgcc-s1 \
|
||
libssl3 \
|
||
python3 \
|
||
libglib2.0-0 \
|
||
wget \
|
||
&& rm -rf /var/lib/apt/lists/* \
|
||
&& apt-get clean
|
||
|
||
# 从 Debian Bullseye 下载并安装 libssl1.1(ZLMediaKit 需要)
|
||
RUN ARCH=$(dpkg --print-architecture) && \
|
||
wget -q http://mirrors.aliyun.com/debian/pool/main/o/openssl/libssl1.1_1.1.1w-0+deb11u1_${ARCH}.deb -O /tmp/libssl1.1.deb && \
|
||
dpkg -i /tmp/libssl1.1.deb || true && \
|
||
rm -f /tmp/libssl1.1.deb && \
|
||
# 移除 wget(不再需要)
|
||
apt-get purge -y wget && \
|
||
apt-get autoremove -y && \
|
||
rm -rf /var/lib/apt/lists/*
|
||
|
||
# 从构建阶段复制 Python 包
|
||
COPY --from=python-builder /python-packages /python-packages
|
||
|
||
# 从外部镜像复制 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
|
||
|
||
# 复制应用文件
|
||
ARG TARGETARCH
|
||
ADD ./build/linux_${TARGETARCH}/bin ./gowvp
|
||
ADD ./www ./www
|
||
ADD ./analysis ./analysis
|
||
|
||
RUN mkdir -p configs && \
|
||
ln -sf /usr/local/bin/ffmpeg /usr/bin/ffmpeg && \
|
||
chmod +x /usr/local/bin/ffmpeg && \
|
||
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"]
|