chore: add auto pip mirror selection by region
This commit is contained in:
@@ -15,6 +15,8 @@ LINGMA_MARKETPLACE_PUBLISHER=Alibaba-Cloud
|
||||
LINGMA_MARKETPLACE_EXTENSION=tongyi-lingma
|
||||
# VSIX 下载地址(最新优先)
|
||||
LINGMA_VSIX_URL=https://tongyi-code.oss-cn-hangzhou.aliyuncs.com/vscode/tongyi-lingma-latest.vsix
|
||||
# 构建 pip 源地区策略:auto/CN/GLOBAL
|
||||
PIP_REGION=auto
|
||||
# 启动时总是尝试从 VSIX 刷新二进制
|
||||
LINGMA_BOOTSTRAP_ALWAYS=true
|
||||
# 强制刷新(true 时忽略本地缓存)
|
||||
|
||||
36
Dockerfile
36
Dockerfile
@@ -5,8 +5,42 @@ WORKDIR /app
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=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 pip install --no-cache-dir -r /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
|
||||
|
||||
COPY app /app/app
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ cp .env.example .env
|
||||
- `LINGMA_MARKETPLACE_PUBLISHER`:Marketplace 发布者
|
||||
- `LINGMA_MARKETPLACE_EXTENSION`:Marketplace 扩展名
|
||||
- `LINGMA_VSIX_URL`:VSIX 下载地址(最新优先)
|
||||
- `PIP_REGION`:构建 pip 源策略(`auto`/`CN`/`GLOBAL`)
|
||||
- `LINGMA_BOOTSTRAP_ALWAYS`:启动时是否总尝试刷新 Lingma
|
||||
- `LINGMA_FORCE_REFRESH`:是否强制刷新(忽略本地缓存)
|
||||
- `LINGMA_WORK_DIR`:Lingma 工作目录(登录与会话数据)
|
||||
@@ -78,6 +79,7 @@ LINGMA_SOURCE_TYPE=marketplace
|
||||
LINGMA_MARKETPLACE_PUBLISHER=Alibaba-Cloud
|
||||
LINGMA_MARKETPLACE_EXTENSION=tongyi-lingma
|
||||
LINGMA_VSIX_URL=https://tongyi-code.oss-cn-hangzhou.aliyuncs.com/vscode/tongyi-lingma-latest.vsix
|
||||
PIP_REGION=auto
|
||||
DEDICATED_DOMAIN_URL=
|
||||
```
|
||||
|
||||
@@ -93,6 +95,11 @@ DEDICATED_DOMAIN_URL=
|
||||
docker compose up -d --build
|
||||
```
|
||||
|
||||
说明:
|
||||
|
||||
- 构建阶段已默认使用腾讯云 PyPI 镜像(`mirrors.cloud.tencent.com`)。
|
||||
- 如需自定义镜像源,可在 `docker-compose.yml` 的 `build.args` 中修改。
|
||||
|
||||
查看日志:
|
||||
|
||||
```bash
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
|
||||
services:
|
||||
lingma-openai-gateway:
|
||||
build: .
|
||||
build:
|
||||
context: .
|
||||
# Use Tencent PyPI mirror during build to avoid timeout.
|
||||
args:
|
||||
PIP_INDEX_URL: https://mirrors.cloud.tencent.com/pypi/simple
|
||||
PIP_TRUSTED_HOST: mirrors.cloud.tencent.com
|
||||
PIP_REGION: auto
|
||||
container_name: lingma-openai-gateway
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
Reference in New Issue
Block a user