feat: 为 Linux 构建脚本添加代理配置和自动重启

- build-adminapi-forlinux.sh: 添加 HTTP_PROXY/HTTPS_PROXY 构建参数
- watch-adminapi-forlinux.sh: 添加代理环境变量和 --restart=always
- watch-tenantapi-forlinux.sh: 添加代理环境变量和 --restart=always
- 代理默认启用,可通过 USE_PROXY=0 禁用

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
root
2026-01-31 09:51:01 +08:00
parent 2f508d7b52
commit 61ecc5dc98
3 changed files with 42 additions and 1 deletions

View File

@@ -19,6 +19,15 @@ if [ "${NO_CACHE:-0}" = "1" ]; then
docker_build_args+=(--no-cache)
fi
# 3. 代理配置(用于 docker build 阶段访问 nuget.org
proxy_host="172.18.0.1"
proxy_port="7890"
if [ "${USE_PROXY:-1}" = "1" ]; then
docker_build_args+=(--build-arg "HTTP_PROXY=http://${proxy_host}:${proxy_port}")
docker_build_args+=(--build-arg "HTTPS_PROXY=http://${proxy_host}:${proxy_port}")
echo "已启用代理http://${proxy_host}:${proxy_port}"
fi
# 2. 先构建镜像(减少停机时间;同时避免每次都删除镜像导致缓存失效)
echo "开始构建镜像:${image_name} (Configuration=${build_configuration})"
docker build -f "${dockerfile_path}" -t "${image_name}" --build-arg "BUILD_CONFIGURATION=${build_configuration}" "${docker_build_args[@]}" "${repo_root}"
@@ -40,7 +49,7 @@ if [ -n "${docker_network}" ]; then
fi
echo "运行新容器:${container_name} (端口映射 7801:7801环境 Development网络 ${docker_network})"
docker run -d --name "${container_name}" "${run_args[@]}" -e ASPNETCORE_ENVIRONMENT=Development -p 7801:7801 "${image_name}"
docker run -d --name "${container_name}" "${run_args[@]}" --restart=always -e ASPNETCORE_ENVIRONMENT=Development -p 7801:7801 "${image_name}"
echo "完成。镜像:${image_name},容器:${container_name}。Swagger 访问http://localhost:7801/swagger"
# 6. 交互式终端下暂停,方便查看输出
if [ -t 0 ]; then