fix: Deploy阶段全面修复 - E2E服务器错位/Worker venv统一/内网Registry登录/生产构建缓存
Deploy / Staging E2E Tests (push) Has been skipped
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Deploy / Deploy Staging (push) Failing after 135h54m40s
CI/CD Pipeline / Frontend Lint (push) Failing after 135h54m55s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 135h54m55s

This commit is contained in:
xiaoxia
2026-07-03 20:59:29 +08:00
parent 9da6ebfb6f
commit bd18acd040
4 changed files with 89 additions and 30 deletions
+37 -2
View File
@@ -28,8 +28,43 @@ if docker ps --format '{{.Names}}' | grep -Eq '^(xiaoxia-(api|web|worker|postgre
fi
fi
docker build --pull=false -f infra/docker/api.Dockerfile -t "$API_IMAGE" -t "$API_LATEST" .
docker build --pull=false -f infra/docker/worker.Dockerfile -t "$WORKER_IMAGE" -t "$WORKER_LATEST" .
# ---- BuildKit 缓存优化 ----
CACHE_REGISTRY="${CACHE_REGISTRY:-git.xiaoxiajianji.com/xiaoxia/xiaoxia-saas}"
CACHE_TAG="${CACHE_TAG:-release}"
USE_CACHE=0
# 检查 buildx 和 Gitea Registry 认证是否可用
if docker buildx version >/dev/null 2>&1; then
# 尝试登录缓存 Registry(有 token 才启用缓存)
if [ -n "${REGISTRY_TOKEN:-}" ]; then
printf '%s' "${REGISTRY_TOKEN}" | docker login git.xiaoxiajianji.com -u xiaoxia --password-stdin 2>/dev/null && USE_CACHE=1
fi
# 确保使用 docker driver(共享 daemon 凭证)
docker buildx use default 2>/dev/null || true
fi
if [ "$USE_CACHE" -eq 1 ]; then
echo "Using buildx with distributed cache (${CACHE_REGISTRY})"
docker buildx build \
--cache-from "type=registry,ref=${CACHE_REGISTRY}/api-cache:${CACHE_TAG},ignore-error=true" \
--cache-to "type=registry,ref=${CACHE_REGISTRY}/api-cache:${CACHE_TAG},mode=max" \
-f infra/docker/api.Dockerfile \
-t "$API_IMAGE" -t "$API_LATEST" \
--load \
.
docker buildx build \
--cache-from "type=registry,ref=${CACHE_REGISTRY}/worker-cache:${CACHE_TAG},ignore-error=true" \
--cache-to "type=registry,ref=${CACHE_REGISTRY}/worker-cache:${CACHE_TAG},mode=max" \
-f infra/docker/worker.Dockerfile \
-t "$WORKER_IMAGE" -t "$WORKER_LATEST" \
--load \
.
else
echo "Buildx cache not available, using plain docker build"
docker build --pull=false -f infra/docker/api.Dockerfile -t "$API_IMAGE" -t "$API_LATEST" .
docker build --pull=false -f infra/docker/worker.Dockerfile -t "$WORKER_IMAGE" -t "$WORKER_LATEST" .
fi
docker save "$API_IMAGE" "$API_LATEST" "$WORKER_IMAGE" "$WORKER_LATEST" -o "$TAR_PATH"
printf '%s\n' "$TAR_PATH"