refactor: Hub二进制改为Docker构建时下载,优化部署流程与worker初始化

- Dockerfile: 移除COPY预编译二进制,改为构建时通过HUB_TAG从GitHub Release下载
- CI: 移除artifact上传/下载步骤,通过build-args传递Hub tag
- deploy.sh: 重构参数解析,支持--hub-tag指定版本,跟踪tag变化触发重建
- build.sh: 新增--image模式支持构建并推送Hub Docker镜像
- hub.rs: worker连接时同步所有节点在线状态,避免状态不一致
- proxy_nodes: 启动时主动建立Hub worker连接,消除懒连接窗口期
- docker-compose.yml: app镜像支持APP_IMAGE环境变量配置
- README: 更新部署文档,推荐本地构建方式
This commit is contained in:
fawney19
2026-03-02 11:24:14 +08:00
parent c9dbe7936b
commit 0564893c4f
12 changed files with 540 additions and 231 deletions
+22 -55
View File
@@ -179,20 +179,24 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
hub_tag: ${{ steps.hub-tag.outputs.tag }}
steps:
- name: Get latest hub release tag
id: hub-tag
run: |
TAG=$(curl -sL "https://api.github.com/repos/${{ env.GITHUB_REPO }}/releases" | \
python3 -c "
import json, sys
releases = json.load(sys.stdin)
for r in releases:
tag = r.get('tag_name', '')
if tag.startswith('hub-v') and not r.get('draft') and not r.get('prerelease'):
print(tag)
break
")
TAG=$(
curl -sL "https://api.github.com/repos/${{ env.GITHUB_REPO }}/releases" | \
python3 - <<'PY'
import json, sys
releases = json.load(sys.stdin)
for r in releases:
tag = r.get('tag_name', '')
if tag.startswith('hub-v') and not r.get('draft') and not r.get('prerelease'):
print(tag)
break
PY
)
if [ -z "$TAG" ]; then
echo "No hub release found"
exit 1
@@ -200,28 +204,6 @@ for r in releases:
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Hub release tag: $TAG"
- name: Download hub binaries
run: |
TAG="${{ steps.hub-tag.outputs.tag }}"
BASE_URL="https://github.com/${{ env.GITHUB_REPO }}/releases/download/$TAG"
mkdir -p hub-binaries/amd64 hub-binaries/arm64
curl -L --fail -o hub-binaries/amd64/aether-hub-linux-amd64.tar.gz "$BASE_URL/aether-hub-linux-amd64.tar.gz"
curl -L --fail -o hub-binaries/arm64/aether-hub-linux-arm64.tar.gz "$BASE_URL/aether-hub-linux-arm64.tar.gz"
tar xzf hub-binaries/amd64/aether-hub-linux-amd64.tar.gz -C hub-binaries/amd64
tar xzf hub-binaries/arm64/aether-hub-linux-arm64.tar.gz -C hub-binaries/arm64
- name: Upload amd64 binary
uses: actions/upload-artifact@v4
with:
name: hub-binary-amd64
path: hub-binaries/amd64/aether-hub
- name: Upload arm64 binary
uses: actions/upload-artifact@v4
with:
name: hub-binary-arm64
path: hub-binaries/arm64/aether-hub
build-app:
needs: [check-base-changes, build-base, download-hub]
if: always() && (needs.build-base.result == 'success' || needs.build-base.result == 'skipped') && needs.download-hub.result == 'success'
@@ -291,25 +273,9 @@ for r in releases:
version_tuple = __version_tuple__
EOF
- name: Download hub binary for amd64
uses: actions/download-artifact@v4
with:
name: hub-binary-amd64
path: aether-hub/dist-amd64
- name: Download hub binary for arm64
uses: actions/download-artifact@v4
with:
name: hub-binary-arm64
path: aether-hub/dist-arm64
- name: Prepare hub binary for build
- name: Resolve hub release for build args
run: |
# 为当前构建平台准备二进制(多架构构建每个平台分别运行)
# 使用 amd64 作为默认,Buildx 会处理多架构
mkdir -p aether-hub/dist
cp aether-hub/dist-amd64/aether-hub aether-hub/dist/aether-hub
chmod +x aether-hub/dist/aether-hub
echo "Hub release tag: ${{ needs.download-hub.outputs.hub_tag }}"
- name: Build and push app image (amd64)
uses: docker/build-push-action@v5
@@ -322,13 +288,11 @@ for r in releases:
no-cache-filters: builder
cache-from: type=gha,scope=app-amd64
cache-to: type=gha,mode=min,scope=app-amd64
build-args: |
HUB_RELEASE_REPO=${{ env.GITHUB_REPO }}
HUB_TAG=${{ needs.download-hub.outputs.hub_tag }}
platforms: linux/amd64
- name: Swap hub binary for arm64
run: |
cp aether-hub/dist-arm64/aether-hub aether-hub/dist/aether-hub
chmod +x aether-hub/dist/aether-hub
- name: Build and push app image (arm64)
uses: docker/build-push-action@v5
with:
@@ -340,4 +304,7 @@ for r in releases:
no-cache-filters: builder
cache-from: type=gha,scope=app-arm64
cache-to: type=gha,mode=min,scope=app-arm64
build-args: |
HUB_RELEASE_REPO=${{ env.GITHUB_REPO }}
HUB_TAG=${{ needs.download-hub.outputs.hub_tag }}
platforms: linux/arm64