feat(deploy,gateway): add dual-edition deployment/migration/rollback and TUN route reconciliation

- Add standalone edition (`Dockerfile.standalone`, `docker-compose.standalone.yml`) alongside sandbox edition and publish both in `.github/workflows/release.yml`.
- Implement `scripts/deploy-lib.sh`, `install.sh`, `update.sh`, and `scripts/artex-sandbox-firewall.sh --cleanup` with edition detection, legacy standalone -> sandbox migration (symlink-safe workspace permissions), automatic snapshots with pinned `artex-rollback/*` images + PG dump, auto/manual cross-edition rollback, and post-rollback upstream unpinning.
- Update `ensureWritableDir` in `internal/sandbox/manager.go` to safely migrate nested root-owned workspace files without following symlinks.
- Expose `deploy_edition` in `/api/update/check` and update `UpdateCard` UI/i18n warnings for sandbox vs standalone in-app update/rollback.
- Reconcile `artex-gateway` TUN policy routing (`priority 218`, `raw PREROUTING`, `nat POSTROUTING`, `DOCKER-USER`) every 15s to self-heal after host network rule flushes or bridge changes.
- Add unit and shell tests (`scripts/deploy_test.sh`, `cmd/artex-gateway/tun_linux_test.go`, `internal/sandbox/sandbox_test.go`, `server/update_test.go`) and update `README.md` / `.env.example`.
This commit is contained in:
ji ruo committed 2026-12-02 13:31:05 +08:00
1 parent d786de90af
commit 07309e4530
23 files changed
+2107 -144

No files matched your search

+84 -3
View File
@@ -257,10 +257,11 @@ jobs:
jq -e --arg version "${RELEASE_TAG#v}" '.version == $version' /tmp/artex-version.json
curl --fail http://127.0.0.1:8787/ > /tmp/artex-index.html
grep -qi '<!doctype html' /tmp/artex-index.html
- name: Push tested architecture image
- name: Push tested control-plane architecture image (sandbox edition)
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: linux/${{ matrix.arch }}
push: true
tags: ${{ vars.ARTEX_DOCKER_IMAGE }}:${{ needs.prepare.outputs.tag }}-${{ matrix.arch }}
@@ -270,8 +271,70 @@ jobs:
org.opencontainers.image.revision=${{ needs.prepare.outputs.commit }}
org.opencontainers.image.licenses=AGPL-3.0
cache-from: type=gha,scope=docker-${{ matrix.arch }}
- name: Build standalone all-in-one image for native smoke test
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.standalone
platforms: linux/${{ matrix.arch }}
load: true
tags: artex-standalone:smoke
cache-from: type=gha,scope=docker-standalone-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=docker-standalone-${{ matrix.arch }}
- name: Smoke test standalone image tools and startup
run: |
docker run --rm --entrypoint sh artex-standalone:smoke -c '
/app/artex -h >/dev/null
python3 --version
nmap --version | head -n 1
playwright-mcp --version
'
- name: Push tested standalone architecture image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.standalone
platforms: linux/${{ matrix.arch }}
push: true
tags: ${{ vars.ARTEX_DOCKER_IMAGE }}:${{ needs.prepare.outputs.tag }}-standalone-${{ matrix.arch }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ needs.prepare.outputs.tag }}
org.opencontainers.image.revision=${{ needs.prepare.outputs.commit }}
org.opencontainers.image.licenses=AGPL-3.0
cache-from: type=gha,scope=docker-standalone-${{ matrix.arch }}
- name: Build and push transparent gateway architecture image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.gateway
platforms: linux/${{ matrix.arch }}
push: true
tags: ${{ vars.ARTEX_DOCKER_IMAGE }}-gateway:${{ needs.prepare.outputs.tag }}-${{ matrix.arch }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ needs.prepare.outputs.tag }}
org.opencontainers.image.revision=${{ needs.prepare.outputs.commit }}
org.opencontainers.image.licenses=AGPL-3.0
cache-from: type=gha,scope=docker-gateway-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=docker-gateway-${{ matrix.arch }}
- name: Build and push sandbox worker architecture image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.sandbox
platforms: linux/${{ matrix.arch }}
push: true
tags: ${{ vars.ARTEX_DOCKER_IMAGE }}-sandbox:${{ needs.prepare.outputs.tag }}-${{ matrix.arch }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ needs.prepare.outputs.tag }}
org.opencontainers.image.revision=${{ needs.prepare.outputs.commit }}
org.opencontainers.image.licenses=AGPL-3.0
cache-from: type=gha,scope=docker-sandbox-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=docker-sandbox-${{ matrix.arch }}
# ⑤ 只有两种架构都通过启动验证,才发布正式版本和 latest 镜像。
# ⑤ 只有两种架构都通过启动验证,才发布双形态(沙箱隔离版 + 单容器版)多架构镜像。
docker-publish:
needs: [prepare, docker]
runs-on: ubuntu-24.04
@@ -281,13 +344,31 @@ jobs:
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish multi-platform image
- name: Publish multi-platform images (sandbox + standalone + gateway + sandbox-worker)
env:
IMAGE: ${{ vars.ARTEX_DOCKER_IMAGE }}
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
run: |
# 1. Control-plane slim image (sandbox edition)
docker buildx imagetools create \
--tag "$IMAGE:$RELEASE_TAG" --tag "$IMAGE:latest" \
"$IMAGE:$RELEASE_TAG-amd64" "$IMAGE:$RELEASE_TAG-arm64"
docker buildx imagetools inspect "$IMAGE:$RELEASE_TAG" --raw > /tmp/artex-manifest.json
jq -e '[.manifests[].platform | select(.os == "linux") | .architecture] | index("amd64") != null and index("arm64") != null' /tmp/artex-manifest.json
# 2. All-in-one standalone image (legacy single-container edition)
docker buildx imagetools create \
--tag "$IMAGE:$RELEASE_TAG-standalone" --tag "$IMAGE:standalone" \
"$IMAGE:$RELEASE_TAG-standalone-amd64" "$IMAGE:$RELEASE_TAG-standalone-arm64"
docker buildx imagetools inspect "$IMAGE:$RELEASE_TAG-standalone" --raw > /tmp/artex-standalone-manifest.json
jq -e '[.manifests[].platform | select(.os == "linux") | .architecture] | index("amd64") != null and index("arm64") != null' /tmp/artex-standalone-manifest.json
# 3. Transparent gateway image
docker buildx imagetools create \
--tag "$IMAGE-gateway:$RELEASE_TAG" --tag "$IMAGE-gateway:latest" \
"$IMAGE-gateway:$RELEASE_TAG-amd64" "$IMAGE-gateway:$RELEASE_TAG-arm64"
# 4. Sandbox worker image
docker buildx imagetools create \
--tag "$IMAGE-sandbox:$RELEASE_TAG" --tag "$IMAGE-sandbox:latest" \
"$IMAGE-sandbox:$RELEASE_TAG-amd64" "$IMAGE-sandbox:$RELEASE_TAG-arm64"