chore: simplify build to fixed Tencent pip mirror
Some checks failed
CI / lint-and-compile (push) Has been cancelled
CI / lint-and-compile (pull_request) Has been cancelled

This commit is contained in:
root
2026-04-17 16:29:18 +08:00
parent d2995b2c48
commit 4e5f451489
4 changed files with 3 additions and 37 deletions

View File

@@ -7,40 +7,11 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
ARG PIP_INDEX_URL=https://mirrors.cloud.tencent.com/pypi/simple
ARG PIP_TRUSTED_HOST=mirrors.cloud.tencent.com
ARG PIP_REGION=auto
COPY requirements.txt /app/requirements.txt
RUN set -e; \
region="${PIP_REGION}"; \
if [ "${region}" = "auto" ]; then \
region=$(python - <<'PY'
import urllib.request
urls = [
"https://ipapi.co/country/",
"https://ifconfig.co/country-iso",
]
for u in urls:
try:
with urllib.request.urlopen(u, timeout=3) as r:
v = r.read().decode("utf-8", errors="ignore").strip().upper()
if v:
print(v)
raise SystemExit(0)
except Exception:
pass
print("UNKNOWN")
PY
); \
fi; \
echo "[build] PIP region=${region}"; \
if [ "${region}" = "CN" ]; then \
pip install --no-cache-dir --retries 5 --timeout 120 \
-i "${PIP_INDEX_URL}" --trusted-host "${PIP_TRUSTED_HOST}" \
-r /app/requirements.txt \
|| pip install --no-cache-dir --retries 5 --timeout 120 -r /app/requirements.txt; \
else \
pip install --no-cache-dir --retries 5 --timeout 120 -r /app/requirements.txt; \
fi
RUN pip install --no-cache-dir --retries 5 --timeout 120 \
-i "${PIP_INDEX_URL}" --trusted-host "${PIP_TRUSTED_HOST}" \
-r /app/requirements.txt
COPY app /app/app