- 更新 Gitea runner 配置,支持优化的 CI/CD 环境 - 完善 Harbor HTTPS 配置和远程访问支持 - 优化 Harbor 日志配置,改用 json-file 驱动 - 添加 Docker 构建加速和代理缓存脚本 - 新增完整的文档和使用指南 - 添加 AI 开发工具集成配置 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
54 lines
1.4 KiB
Bash
Executable File
54 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# 本地镜像自动推送到 Harbor
|
|
# 扫描本地镜像,自动推送到 Harbor
|
|
|
|
set -e
|
|
|
|
HARBOR_REGISTRY="192.168.1.83:8443"
|
|
PROJECT_NAME="ljwx"
|
|
|
|
echo "🔍 扫描本地镜像..."
|
|
|
|
# 获取本地镜像列表(排除 Harbor 镜像和中间层)
|
|
local_images=$(docker images --format "table {{.Repository}}:{{.Tag}}" | \
|
|
grep -v "${HARBOR_REGISTRY}" | \
|
|
grep -v "REPOSITORY:TAG" | \
|
|
grep -v "<none>" | \
|
|
head -10)
|
|
|
|
if [ -z "$local_images" ]; then
|
|
echo "📭 没有找到需要推送的本地镜像"
|
|
exit 0
|
|
fi
|
|
|
|
echo "发现以下本地镜像:"
|
|
echo "$local_images"
|
|
echo
|
|
|
|
read -p "是否推送到 Harbor? (y/N): " confirm
|
|
if [[ $confirm != [yY] ]]; then
|
|
echo "❌ 操作取消"
|
|
exit 0
|
|
fi
|
|
|
|
# 推送镜像
|
|
while IFS= read -r image; do
|
|
if [ -n "$image" ] && [ "$image" != "REPOSITORY:TAG" ] && [[ "$image" != *"docker.io"* ]]; then
|
|
# 构建 Harbor 镜像名
|
|
repo=$(echo "$image" | cut -d':' -f1 | sed 's|.*/||')
|
|
tag=$(echo "$image" | cut -d':' -f2)
|
|
harbor_image="${HARBOR_REGISTRY}/${PROJECT_NAME}/${repo}:${tag}"
|
|
|
|
echo "📦 推送: $image → $harbor_image"
|
|
|
|
# 标记并推送
|
|
docker tag "$image" "$harbor_image"
|
|
docker push "$harbor_image"
|
|
|
|
# 清理本地标签(可选)
|
|
# docker rmi "$harbor_image" 2>/dev/null || true
|
|
fi
|
|
done <<< "$local_images"
|
|
|
|
echo "✅ 镜像推送完成" |