f651422582
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 2s
CI/CD Pipeline / Check push changed paths (push) Successful in 11s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 39s
CI/CD Pipeline / Integration Tests (push) Successful in 3m18s
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 3m21s
CI/CD Pipeline / Validate - Style (push) Successful in 3m54s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 5m16s
CI/CD Pipeline / Validate - Security (push) Successful in 8m17s
CI/CD Pipeline / Unit Tests (push) Successful in 8m42s
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Build Staging API Image (push) Successful in 14m38s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 18m14s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 5m19s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 1m26s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 2m58s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 3m1s
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Failing after 51h35m15s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 51h44m59s
CI/CD Pipeline / PR Build Web Image (push) Failing after 51h53m46s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 51h53m21s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 51h53m20s
CI/CD Pipeline / PR Build API Image (push) Failing after 51h53m20s
CI/CD Pipeline / Deploy Production (push) Failing after 51h44m31s
CI/CD Pipeline / Build Production Web Image (push) Failing after 51h44m33s
CI/CD Pipeline / Build Production API Image (push) Failing after 51h44m33s
CI/CD Pipeline / CI Gate (push) Failing after 51h44m33s
CI/CD Pipeline / Retag skipped Staging Web Image (push) Failing after 51h34m50s
CI/CD Pipeline / Retag skipped Staging API Image (push) Failing after 51h34m50s
CI/CD Pipeline / Canary Release to Production (push) Failing after 51h26m28s
CI/CD Pipeline / Frontend Lint (push) Failing after 51h53m16s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
104 lines
2.6 KiB
Bash
Executable File
104 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# ============================================
|
|
# 基础镜像同步脚本 - 从公共镜像源同步到私有ACR
|
|
# 用法:
|
|
# ACR_USERNAME=xxx ACR_PASSWORD=yyy bash scripts/ci/sync_base_images.sh
|
|
# ============================================
|
|
|
|
set -euo pipefail
|
|
|
|
ACR_REGISTRY="${ACR_REGISTRY:-xiaoxia-registry.cn-hangzhou.cr.aliyuncs.com/xiaoxiakeji}"
|
|
ACR_USERNAME="${ACR_USERNAME:-}"
|
|
ACR_PASSWORD="${ACR_PASSWORD:-}"
|
|
SOURCE_PREFIX="${SOURCE_PREFIX:-docker.m.daocloud.io/library}"
|
|
|
|
# 需要同步的镜像列表 (源镜像名:tag => ACR目标名:tag)
|
|
IMAGES=(
|
|
"python:3.12-slim-bookworm"
|
|
"python:3.12-slim"
|
|
"node:20"
|
|
"nginx:alpine"
|
|
)
|
|
|
|
echo "============================================"
|
|
echo " 基础镜像同步到 ACR"
|
|
echo " ACR: $ACR_REGISTRY"
|
|
echo " 源: $SOURCE_PREFIX"
|
|
echo "============================================"
|
|
echo ""
|
|
|
|
# 登录 ACR
|
|
if [ -n "$ACR_PASSWORD" ] && [ -n "$ACR_USERNAME" ]; then
|
|
echo "登录 ACR..."
|
|
ACR_HOST=$(echo "$ACR_REGISTRY" | cut -d/ -f1)
|
|
printf '%s' "$ACR_PASSWORD" | docker login "$ACR_HOST" -u "$ACR_USERNAME" --password-stdin
|
|
echo "ACR 登录成功"
|
|
echo ""
|
|
fi
|
|
|
|
success=0
|
|
failed=0
|
|
|
|
for image in "${IMAGES[@]}"; do
|
|
source_image="${SOURCE_PREFIX}/${image}"
|
|
target_image="${ACR_REGISTRY}/base/${image}"
|
|
|
|
echo "--- 同步: $image ---"
|
|
echo " 源: $source_image"
|
|
echo " 目标: $target_image"
|
|
|
|
# Pull 源镜像(带重试)
|
|
pulled=0
|
|
for attempt in 1 2 3; do
|
|
echo " Pull 尝试 $attempt/3..."
|
|
if docker pull "$source_image"; then
|
|
pulled=1
|
|
break
|
|
fi
|
|
echo " Pull 失败,5s 后重试..."
|
|
sleep 5
|
|
done
|
|
|
|
if [ "$pulled" -eq 0 ]; then
|
|
echo " ❌ Pull 失败: $image"
|
|
failed=$((failed + 1))
|
|
continue
|
|
fi
|
|
|
|
# Tag
|
|
docker tag "$source_image" "$target_image"
|
|
echo " Tag 完成"
|
|
|
|
# Push 到 ACR
|
|
pushed=0
|
|
for attempt in 1 2 3; do
|
|
echo " Push 尝试 $attempt/3..."
|
|
if docker push "$target_image"; then
|
|
pushed=1
|
|
break
|
|
fi
|
|
echo " Push 失败,5s 后重试..."
|
|
sleep 5
|
|
done
|
|
|
|
if [ "$pushed" -eq 1 ]; then
|
|
echo " ✅ 同步成功: $image"
|
|
success=$((success + 1))
|
|
else
|
|
echo " ❌ Push 失败: $image"
|
|
failed=$((failed + 1))
|
|
fi
|
|
|
|
echo ""
|
|
done
|
|
|
|
echo "============================================"
|
|
echo " 同步完成"
|
|
echo " 成功: $success"
|
|
echo " 失败: $failed"
|
|
echo "============================================"
|
|
|
|
if [ "$failed" -gt 0 ]; then
|
|
exit 1
|
|
fi
|