test11
Some checks failed
Build and Push to ACR / docker (push) Has been cancelled

This commit is contained in:
2025-09-30 21:51:33 +08:00
parent 8decad32b9
commit 83ded96b63

View File

@@ -54,7 +54,7 @@ jobs:
# 0) Secret 非空
[ -n "${V2RAY_JSON:-}" ] || { echo "V2RAY_JSON is empty"; exit 1; }
# 1) 先在 runner 容器里修正端口(可选但推荐)
# 1) 在工作区生成 config.json并将 inbounds 端口改成我们想要的
mkdir -p "${GITHUB_WORKSPACE}/v2ray"
printf '%s' "$V2RAY_JSON" > "${GITHUB_WORKSPACE}/v2ray/config.json"
if command -v jq >/dev/null 2>&1; then
@@ -67,25 +67,26 @@ jobs:
> "${GITHUB_WORKSPACE}/v2ray/config.tmp" && mv "${GITHUB_WORKSPACE}/v2ray/config.tmp" "${GITHUB_WORKSPACE}/v2ray/config.json"
fi
# 2) base64 编码(兼容不同 base64 实现)
# 2) base64 编码(兼容不同实现)
if base64 --help 2>&1 | grep -q -- '-w'; then
CONF_B64="$(base64 -w0 < "${GITHUB_WORKSPACE}/v2ray/config.json")"
else
CONF_B64="$(base64 < "${GITHUB_WORKSPACE}/v2ray/config.json" | tr -d '\n')"
fi
# 3) 启动容器:用 entrypoint 写入配置 exec v2ray;不再做 bind-mount
# 3) 以 host 网络启动;覆盖 ENTRYPOINT 为 /bin/sh配置 exec v2ray
docker rm -f v2ray-client >/dev/null 2>&1 || true
docker run -d --name v2ray-client \
--network host \
-e CONF_B64="${CONF_B64}" \
--entrypoint /bin/sh \
v2fly/v2fly-core:latest \
sh -lc 'set -euo pipefail;
mkdir -p /etc/v2ray;
printf "%s" "$CONF_B64" | base64 -d > /etc/v2ray/config.json;
exec v2ray run -c /etc/v2ray/config.json'
-lc 'set -euo pipefail;
mkdir -p /etc/v2ray;
printf "%s" "$CONF_B64" | base64 -d > /etc/v2ray/config.json;
exec /usr/bin/v2ray run -c /etc/v2ray/config.json'
# 4) 健康检查 + 日志打印
# 4) 健康检查 + 日志
sleep 1
if [ "$(docker inspect -f '{{.State.Running}}' v2ray-client 2>/dev/null)" != "true" ]; then
echo "== v2ray-client exited; logs =="
@@ -94,8 +95,6 @@ jobs:
fi
echo "v2ray-client is running."
- name: Build Docker Image (host network; no Dockerfile change)
env:
IMAGE: ${{ secrets.ACR_REGISTRY }}/${{ secrets.ACR_NAMESPACE }}/${{ vars.IMAGE_NAME }}