From 83ded96b63752fc32ca5f9c17b598f81911aac3f Mon Sep 17 00:00:00 2001 From: hotwa Date: Tue, 30 Sep 2025 21:51:33 +0800 Subject: [PATCH] test11 --- .gitea/workflows/build-and-push.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.gitea/workflows/build-and-push.yml b/.gitea/workflows/build-and-push.yml index 398d928..be80110 100644 --- a/.gitea/workflows/build-and-push.yml +++ b/.gitea/workflows/build-and-push.yml @@ -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 }}