Files
docker-registry/kami-spider-monorepo/build-base-image.sh
danial 6f274a3e2e chore(ci): 优化基础镜像构建脚本并移除冗余文件
- 在 CI 脚本中增加对必需构建文件的校验,避免缺失文件导致构建失败
- 添加构建成功后镜像验证步骤,并输出镜像详情
- 移除 `kami-spider-monorepo` 目录下的 Dockerfile、Makefile、README.md 和入口脚本,简化项目结构
- 调整基础镜像构建脚本 `build-base-image.sh`,指定正确的 Dockerfile 文件名
- 更新 README 使其内容更加精简,聚焦于基础镜像构建和使用说明
2025-11-09 15:11:42 +08:00

54 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Build script for kami-spider combined base Docker image
# This script creates a single comprehensive base image
set -e
# Configuration
BASE_IMAGE_NAME="kami-spider-base"
REGISTRY="${DOCKER_REGISTRY:-localhost:5000}"
VERSION="${VERSION:-latest}"
USE_PROXY="${USE_PROXY:-0}"
echo "🏗️ Building kami-spider combined base Docker image..."
echo "Registry: $REGISTRY"
echo "Version: $VERSION"
echo "Use Proxy: $USE_PROXY"
echo
# Build the combined base image (system + Python dependencies + Playwright)
echo "📦 Building combined base image ($BASE_IMAGE_NAME)..."
docker build \
--file Dockerfile.base \
--tag "$BASE_IMAGE_NAME:$VERSION" \
--tag "$BASE_IMAGE_NAME:latest" \
--build-arg USE_PROXY="$USE_PROXY" \
.
# Tag for registry if specified
if [ "$REGISTRY" != "localhost:5000" ]; then
docker tag "$BASE_IMAGE_NAME:$VERSION" "$REGISTRY/$BASE_IMAGE_NAME:$VERSION"
docker tag "$BASE_IMAGE_NAME:latest" "$REGISTRY/$BASE_IMAGE_NAME:latest"
fi
echo "✅ Combined base image built successfully!"
# Push to registry if specified
if [ "$REGISTRY" != "localhost:5000" ]; then
echo "🚀 Pushing image to registry..."
docker push "$REGISTRY/$BASE_IMAGE_NAME:$VERSION"
docker push "$REGISTRY/$BASE_IMAGE_NAME:latest"
echo "✅ Image pushed to registry successfully!"
fi
echo
echo "🎉 Build completed successfully!"
echo "Available images:"
echo " - $BASE_IMAGE_NAME:$VERSION"
echo " - $BASE_IMAGE_NAME:latest"
# Display image size
echo
echo "📊 Image size:"
docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" | grep "$BASE_IMAGE_NAME"