Files
docker-registry/kami-spider-monorepo/build-base-image.sh
danial 716a72b8ab feat(ci): 添加 Spider Base 镜像构建和部署流水线
- 新增 .drone.yml 配置,实现基于 SSH 的自动构建和推送 Spider Base 镜像
- 检测 kami-spider-monorepo 目录代码变动,变动时触发基础镜像构建
- 基础镜像包含系统依赖、Python 环境、Playwright 及所有项目依赖
- 优化 Dockerfile,将应用镜像基于该预构建基础镜像构建,显著提升构建速度
- 新增 Makefile,标准化基础镜像和应用镜像的构建、测试、推送及清理流程
- 增加详细的 README,指导开发者快速上手构建和使用基础镜像
- 添加构建脚本 build-base-image.sh,实现基础镜像的统一构建及推送
- 引入生产环境入口脚本 docker-entrypoint.sh,优化启动流程和信号处理
- 统一依赖管理(pyproject.toml、uv.lock),确保基础镜像依赖完整一致
- 设定健康检查,提升容器运行稳定性和可监控性
2025-11-09 15:08:38 +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-combined \
--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"