利用 AI 大模型和自动化工作流,根据主题或关键词一键生成高清短视频。Generate HD short videos from a topic or keyword with an automated AI workflow.
Python ai-video-generatorcontent-creationffmpeginstagram-reelsllmpythonshort-videosubtitlestext-to-speechtiktokvideo-automationvideo-workflowworkflow-automationyoutube-shorts
fix(docker): fail when dependency install fails
harry0703fec27211834d
diff --git a/Dockerfile b/Dockerfileindex 8a0c46c5..c8dde711 100644--- a/Dockerfile+++ b/Dockerfile@@ -14,41 +14,70 @@ ENV PYTHONPATH="/MoneyPrinterTurbo"ARG DOCKER_BUILD_MIRROR=chinaARG PIP_USE_OFFICIAL=0-# Install system dependencies with retry logic-RUN if [ "$DOCKER_BUILD_MIRROR" = "china" ]; then \- echo "deb http://mirrors.aliyun.com/debian bullseye main" > /etc/apt/sources.list && \- echo "deb http://mirrors.aliyun.com/debian-security bullseye-security main" >> /etc/apt/sources.list; \+# 系统依赖安装需要同时满足两点:国内环境保留镜像回退能力,所有镜像均+# 失败时必须让 Docker 构建立刻失败。旧循环最后执行的 sleep 总会返回 0,+# 导致 git/ffmpeg 未安装时仍生成不可用镜像。这里把“写入软件源”“安装”+# 和“三次重试”拆成边界清晰的 shell 函数,并用函数返回值决定是否继续。+# 所有软件源统一使用 HTTPS,避免部分网络环境直接拦截明文 HTTP 请求。+RUN set -u; \+ write_debian_sources() { \+ main_url="$1"; \+ security_url="$2"; \+ printf 'deb %s bullseye main\ndeb %s bullseye-updates main\ndeb %s bullseye-security main\n' \+ "$main_url" "$main_url" "$security_url" > /etc/apt/sources.list; \+ rm -rf /var/lib/apt/lists/*; \+ }; \+ install_system_dependencies() { \+ apt-get update && \+ apt-get install -y --no-install-recommends git ffmpeg; \+ }; \+ retry_system_dependencies() { \+ attempt=1; \+ while [ "$attempt" -le 3 ]; do \+ echo "Attempt $attempt: installing system dependencies"; \+ if install_system_dependencies; then \+ return 0; \+ fi; \+ echo "Attempt $attempt failed" >&2; \+ if [ "$attempt" -lt 3 ]; then \+ echo "Retrying in 5 seconds..." >&2; \+ sleep 5; \+ fi; \+ attempt=$((attempt + 1)); \+ done; \+ return 1; \+ }; \+ if [ "$DOCKER_BUILD_MIRROR" = "china" ]; then \+ write_debian_sources \+ "https://mirrors.aliyun.com/debian" \+ "https://mirrors.aliyun.com/debian-security"; \+ if ! retry_system_dependencies; then \+ echo "Aliyun mirror failed, switching to Tsinghua mirror" >&2; \+ write_debian_sources \+ "https://mirrors.tuna.tsinghua.edu.cn/debian" \+ "https://mirrors.tuna.tsinghua.edu.cn/debian-security"; \+ if ! install_system_dependencies; then \+ echo "Tsinghua mirror failed, switching to default Debian mirror" >&2; \+ write_debian_sources \+ "https://deb.debian.org/debian" \+ "https://deb.debian.org/debian-security"; \+ if ! install_system_dependencies; then \+ echo "Failed to install system dependencies from all configured mirrors" >&2; \+ exit 1; \+ fi; \+ fi; \+ fi; \else \echo "Using default Debian mirrors"; \- fi && \- ( \- for i in 1 2 3; do \- echo "Attempt $i: installing system dependencies"; \- apt-get update && apt-get install -y --no-install-recommends \- git \- ffmpeg && break || \- echo "Attempt $i failed, retrying..."; \- if [ "$DOCKER_BUILD_MIRROR" = "china" ] && [ $i -eq 3 ]; then \- echo "Aliyun mirror failed, switching to Tsinghua mirror"; \- sed -i 's/mirrors.aliyun.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \- sed -i 's/mirrors.aliyun.com\/debian-security/mirrors.tuna.tsinghua.edu.cn\/debian-security/g' /etc/apt/sources.list && \- ( \- apt-get update && apt-get install -y --no-install-recommends \- git \- ffmpeg || \- ( \- echo "Tsinghua mirror failed, switching to default Debian mirror"; \- sed -i 's/mirrors.tuna.tsinghua.edu.cn/deb.debian.org/g' /etc/apt/sources.list && \- sed -i 's/mirrors.tuna.tsinghua.edu.cn\/debian-security/security.debian.org/g' /etc/apt/sources.list; \- apt-get update && apt-get install -y --no-install-recommends \- git \- ffmpeg; \- ); \- ); \- fi; \- sleep 5; \- done \- ) && rm -rf /var/lib/apt/lists/*+ write_debian_sources \+ "https://deb.debian.org/debian" \+ "https://deb.debian.org/debian-security"; \+ if ! retry_system_dependencies; then \+ echo "Failed to install system dependencies from the default Debian mirror" >&2; \+ exit 1; \+ fi; \+ fi; \+ rm -rf /var/lib/apt/lists/*# Copy only the requirements.txt first to leverage Docker cacheCOPY requirements.txt ./diff --git a/Dockerfile.gpu b/Dockerfile.gpuindex 5a5b5b34..a20ee812 100644--- a/Dockerfile.gpu+++ b/Dockerfile.gpu@@ -10,7 +10,9 @@ RUN chmod 777 /MoneyPrinterTurboENV PYTHONPATH="/MoneyPrinterTurbo"-# Install Python 3.11 and system dependencies+# 安装链中的任何前置步骤失败都必须终止构建。只有删除系统自带 blinker+# 属于可忽略操作,因此把容错限制在该子命令的括号内,避免末尾的+# `|| true` 把 apt、PPA、Python 或 pip 安装失败一并转换成成功状态。RUN apt-get update && apt-get install -y --no-install-recommends \software-properties-common \git \@@ -25,7 +27,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \&& ln -sf /usr/bin/python3.11 /usr/bin/python3 \&& ln -sf /usr/bin/python3.11 /usr/bin/python \&& python3.11 -m pip install --upgrade pip \- && apt-get remove -y python3-blinker || true \+ && (apt-get remove -y python3-blinker || \+ echo "python3-blinker removal skipped; continuing") \&& rm -rf /var/lib/apt/lists/*# Copy only the requirements.txt first to leverage Docker cache