Build & Push - 构建并推送镜像 / 构建后端镜像 (push) Failing after 0s
Build & Push - 构建并推送镜像 / 构建前端镜像 (push) Failing after 0s
Build & Push - 构建并推送镜像 / 构建通知 (push) Failing after 0s
CI - 代码检查和测试 / Python 代码检查 (push) Failing after 0s
CI - 代码检查和测试 / Python 单元测试 (push) Failing after 0s
CI - 代码检查和测试 / Frontend 代码检查 (push) Failing after 0s
CI - 代码检查和测试 / Frontend 构建测试 (push) Failing after 0s
This commit introduces a comprehensive DevOps infrastructure supporting local development, Docker Compose, and Kubernetes deployments. Features: - One-click local startup script (start_app.sh) * Auto Python 3.12 virtual environment management * Smart dependency installation with USTC pip mirror * Concurrent backend and frontend startup * Graceful shutdown with Ctrl+C - Docker deployment (docker-compose.prod.yml) * Multi-stage optimized Dockerfiles * Pull from localhost:5000 (business) and :5001 (base cache) * Complete service stack: Backend + Frontend + PostgreSQL + Redis + Nginx * Health checks and auto-restart - Kubernetes deployment (deploy_k8s.sh) * Full K8s configurations (8 YAML files) * ConfigMap/Secret management * HPA auto-scaling for backend * Ingress routing - CI/CD with Gitea Actions * Code quality checks (black, ruff, mypy) * Automated testing with coverage reports * Auto build and push images * Auto deploy to K8s dev/prod - Dependency caching * pip: USTC mirror (https://pypi.mirrors.ustc.edu.cn/simple/) * npm: Taobao mirror (https://registry.npmmirror.com) * Docker: localhost:5001 pull-through cache - Testing and notifications * HTML test reports * Code coverage visualization * QQ email notifications ([email protected]) Documentation: - DEVOPS_SOLUTION.md: Complete architecture design - DEVOPS_QUICKSTART.md: Step-by-step guide - README_DEVOPS.md: DevOps overview - DEVOPS_FILES.md: File reference Total: 30+ configuration files and scripts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
178 lines
4.7 KiB
Bash
Executable File
178 lines
4.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
###############################################################################
|
|
# 依赖缓存配置脚本
|
|
# 功能: 配置 pip 和 npm 镜像源,加速依赖下载
|
|
###############################################################################
|
|
|
|
set -e
|
|
|
|
# 颜色定义
|
|
GREEN='\033[0;32m'
|
|
BLUE='\033[0;34m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
log_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
log_success() {
|
|
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
}
|
|
|
|
log_warning() {
|
|
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
}
|
|
|
|
# 配置 pip 镜像源
|
|
setup_pip_mirror() {
|
|
log_info "配置 pip 镜像源..."
|
|
|
|
# 创建 pip 配置目录
|
|
PIP_CONFIG_DIR="$HOME/.pip"
|
|
mkdir -p "$PIP_CONFIG_DIR"
|
|
|
|
# 复制配置文件
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"
|
|
if [ -f "$SCRIPT_DIR/.pip/pip.conf" ]; then
|
|
cp "$SCRIPT_DIR/.pip/pip.conf" "$PIP_CONFIG_DIR/pip.conf"
|
|
log_success "pip 镜像源配置完成: 中科大镜像"
|
|
else
|
|
log_warning "pip 配置文件不存在,手动创建"
|
|
|
|
cat > "$PIP_CONFIG_DIR/pip.conf" <<'EOF'
|
|
[global]
|
|
index-url = https://pypi.mirrors.ustc.edu.cn/simple/
|
|
trusted-host = pypi.mirrors.ustc.edu.cn
|
|
timeout = 120
|
|
disable-pip-version-check = true
|
|
|
|
[install]
|
|
cache-dir = ~/.cache/pip
|
|
EOF
|
|
log_success "pip 镜像源配置完成: 中科大镜像"
|
|
fi
|
|
|
|
# 验证配置
|
|
pip config list
|
|
}
|
|
|
|
# 配置 npm 镜像源
|
|
setup_npm_mirror() {
|
|
log_info "配置 npm 镜像源..."
|
|
|
|
# 方法1: 使用 .npmrc 文件
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"
|
|
if [ -f "$SCRIPT_DIR/.npmrc" ]; then
|
|
cp "$SCRIPT_DIR/.npmrc" "$HOME/.npmrc"
|
|
log_success "npm 镜像源配置完成: 淘宝镜像"
|
|
else
|
|
log_warning "npm 配置文件不存在,手动配置"
|
|
|
|
npm config set registry https://registry.npmmirror.com
|
|
npm config set sass_binary_site https://npmmirror.com/mirrors/node-sass
|
|
npm config set phantomjs_cdnurl https://npmmirror.com/mirrors/phantomjs
|
|
npm config set electron_mirror https://npmmirror.com/mirrors/electron
|
|
npm config set cache ~/.npm
|
|
npm config set loglevel error
|
|
|
|
log_success "npm 镜像源配置完成"
|
|
fi
|
|
|
|
# 验证配置
|
|
npm config get registry
|
|
}
|
|
|
|
# 配置 Docker 镜像缓存
|
|
setup_docker_mirror() {
|
|
log_info "检查 Docker 镜像缓存配置..."
|
|
|
|
# OrbStack 的配置路径
|
|
DOCKER_CONFIG="$HOME/.docker/daemon.json"
|
|
|
|
if [ -f "$DOCKER_CONFIG" ]; then
|
|
log_info "Docker 配置文件已存在"
|
|
cat "$DOCKER_CONFIG"
|
|
else
|
|
log_warning "Docker 配置文件不存在"
|
|
log_info "请手动配置 Docker 镜像缓存:"
|
|
echo ""
|
|
echo "1. OrbStack: 打开 OrbStack 设置 -> Docker -> Registry Mirrors"
|
|
echo "2. 添加镜像缓存: http://localhost:5001"
|
|
echo ""
|
|
log_info "或者创建 $DOCKER_CONFIG 文件:"
|
|
cat <<'EOF'
|
|
{
|
|
"registry-mirrors": [
|
|
"http://localhost:5001"
|
|
]
|
|
}
|
|
EOF
|
|
fi
|
|
}
|
|
|
|
# 测试镜像源速度
|
|
test_mirrors() {
|
|
log_info "测试镜像源速度..."
|
|
|
|
echo ""
|
|
log_info "测试 pip 镜像源..."
|
|
time pip install --dry-run requests 2>&1 | head -5 || true
|
|
|
|
echo ""
|
|
log_info "测试 npm 镜像源..."
|
|
time npm info vue 2>&1 | head -5 || true
|
|
|
|
echo ""
|
|
log_success "镜像源测试完成"
|
|
}
|
|
|
|
# 显示帮助信息
|
|
show_info() {
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
log_success "依赖缓存配置完成"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
echo "📦 Python (pip)"
|
|
echo " 配置文件: ~/.pip/pip.conf"
|
|
echo " 镜像源: https://pypi.mirrors.ustc.edu.cn/simple/"
|
|
echo " 缓存目录: ~/.cache/pip"
|
|
echo ""
|
|
echo "📦 Node.js (npm)"
|
|
echo " 配置文件: ~/.npmrc"
|
|
echo " 镜像源: https://registry.npmmirror.com"
|
|
echo " 缓存目录: ~/.npm"
|
|
echo ""
|
|
echo "🐳 Docker"
|
|
echo " 镜像缓存: localhost:5001"
|
|
echo " 配置文件: ~/.docker/daemon.json (需手动配置)"
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
}
|
|
|
|
# 主函数
|
|
main() {
|
|
log_info "开始配置依赖缓存..."
|
|
echo ""
|
|
|
|
setup_pip_mirror
|
|
echo ""
|
|
|
|
setup_npm_mirror
|
|
echo ""
|
|
|
|
setup_docker_mirror
|
|
echo ""
|
|
|
|
# test_mirrors
|
|
# echo ""
|
|
|
|
show_info
|
|
}
|
|
|
|
# 运行主函数
|
|
main
|