优化国内访问问题

This commit is contained in:
2026-10-19 00:23:28 +08:00
parent 6b40ced355
commit 4dd51ba18c
2 changed files with 28 additions and 3 deletions
+15
View File
@@ -1,5 +1,20 @@
FROM node:22-slim
# 国内构建慢:apt/pip 默认源在国外,apt-get update 能卡十几分钟。默认换成腾讯云镜像。
# 境外构建或想换源:docker compose build --build-arg DEBIAN_MIRROR=deb.debian.org
# 腾讯云 CVM 上想更快可用内网镜像 mirrors.tencentyun.com(仅腾讯云内网可达)。
ARG DEBIAN_MIRROR=mirrors.cloud.tencent.com
# 换 apt 源:bookworm 可能是 /etc/apt/sources.list,也可能是 deb822 的 /etc/apt/sources.list.d/*.sources,
# 直接用 grep 扫一遍、只替换域名,两种格式都盖住(路径 /debian、/debian-security 保持不变)。
RUN set -eux; \
files="$(grep -rl 'deb.debian.org' /etc/apt/ 2>/dev/null || true)"; \
if [ -n "$files" ]; then sed -i "s|deb.debian.org|${DEBIAN_MIRROR}|g" $files; fi; \
grep -rn "${DEBIAN_MIRROR}" /etc/apt/ | head -5 || true
# TZ=Asia/Shanghai:统一时区。
ENV TZ=Asia/Shanghai
# libssl3: officecli is a .NET self-contained binary and hard-requires libssl.
# ICU is NOT needed: DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 disables globalization.
# curl: the entrypoint fetches the officecli binary at FIRST boot (image intentionally
+13 -3
View File
@@ -42,16 +42,26 @@ tmp="$(mktemp "${BIN_DIR}/.dl.XXXXXX")" # 与目标同目录:最后 m
trap 'rm -f "${tmp}"' EXIT
for url in "${urls[@]}"; do
log "trying ${url}"
if curl -fsSL --connect-timeout 10 --retry 1 --max-time 600 -o "${tmp}" "${url}"; then
log "trying ${url} (connect<=10s, speed>=10KB/s, max 300s)"
t0=$(date +%s)
if curl -fL \
--connect-timeout 10 \
--max-time 300 \
--speed-limit 102400 \
--speed-time 20 \
--retry 1 \
--progress-bar \
-o "${tmp}" "${url}"; then
got="$(sha256sum "${tmp}" | awk '{print $1}')"
if [ "${got}" = "${SHA256}" ]; then
chmod +x "${tmp}"
mv -f "${tmp}" "${BIN}"
log "officecli ${VERSION} installed -> ${BIN}"
log "officecli ${VERSION} installed -> ${BIN} ($(( $(date +%s) - t0 ))s)"
exec "$@"
fi
log "sha256 mismatch (got ${got}), trying next source"
else
log "failed after $(( $(date +%s) - t0 ))s: ${url}"
fi
rm -f "${tmp}"
done