Browse Source

更新发布sh

feature/web_v4.0
hyh 3 weeks ago
parent
commit
254097e026
  1. 24
      modify.md
  2. 37
      site/deploy-https.sh

24
modify.md

@ -19,12 +19,17 @@
- 尝试删除 Docker 网络 - 尝试删除 Docker 网络
- 如果网络仍在使用中则跳过删除 - 如果网络仍在使用中则跳过删除
3. **服务启动** 3. **镜像清理**
- 清理未使用的镜像(dangling images)
- 清理构建缓存
- 确保每次都是全新构建
4. **服务启动**
- 使用 docker-compose 启动服务 - 使用 docker-compose 启动服务
- 自动构建镜像(`--build`) - 构建时使用 `--no-cache` 选项,不使用缓存
- 后台运行(`-d`) - 后台运行(`-d`)
4. **状态检查** 5. **状态检查**
- 等待容器启动 - 等待容器启动
- 显示容器运行状态 - 显示容器运行状态
@ -55,6 +60,19 @@
变更原因:用户需要在 CentOS 环境中快速部署 HTTPS 版本,需要自动清除之前的容器并重新部署,避免手动操作步骤繁琐。 变更原因:用户需要在 CentOS 环境中快速部署 HTTPS 版本,需要自动清除之前的容器并重新部署,避免手动操作步骤繁琐。
**后续修复**:
- **修复 docker-compose 命令兼容性问题**:脚本现在会自动检测并使用正确的 Docker Compose 命令
- 优先尝试使用 `docker compose`(Docker CLI 插件,新版本)
- 如果不存在,则使用 `docker-compose`(独立命令,旧版本)
- 如果两者都不存在,脚本会报错并退出
- 修复了 "docker-compose: command not found" 错误
- **添加 Docker 镜像和构建缓存清理功能**
- 在部署前自动清理未使用的镜像(`docker image prune -f`)
- 清理构建缓存(`docker builder prune -f`)
- 构建时使用 `--no-cache` 选项,确保不使用缓存的镜像层
- 解决因缓存导致的构建问题,确保每次部署都是全新构建
## 2025-01-XX - 修复 Next.js 配置警告 ## 2025-01-XX - 修复 Next.js 配置警告
### 修复内容 ### 修复内容

37
site/deploy-https.sh

@ -13,6 +13,19 @@ echo "=========================================="
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR" cd "$SCRIPT_DIR"
# Detect docker compose command (new version: "docker compose" or old version: "docker-compose")
if docker compose version >/dev/null 2>&1; then
DOCKER_COMPOSE="docker compose"
elif docker-compose version >/dev/null 2>&1; then
DOCKER_COMPOSE="docker-compose"
else
echo "Error: Neither 'docker compose' nor 'docker-compose' command found"
echo "Please install Docker Compose"
exit 1
fi
echo "Using: $DOCKER_COMPOSE"
# Define container names # Define container names
MARKETING_CONTAINER="marketing-site-https" MARKETING_CONTAINER="marketing-site-https"
NGINX_CONTAINER="nginx-https" NGINX_CONTAINER="nginx-https"
@ -54,14 +67,28 @@ else
fi fi
echo "" echo ""
echo "Step 3: Starting services with docker-compose..." echo "Step 3: Cleaning up Docker images and build cache..."
echo "----------------------------------------"
# Remove dangling images (untagged images)
echo "Removing dangling images..."
docker image prune -f || true
# Remove build cache to ensure fresh build
echo "Removing build cache..."
docker builder prune -f || true
echo ""
echo "Step 4: Starting services with docker-compose (no cache)..."
echo "----------------------------------------" echo "----------------------------------------"
# Start services with docker-compose (will automatically create network and volumes) # Start services with docker-compose (will automatically create network and volumes)
docker-compose -f docker-compose-https.yml up -d --build # Use --no-cache to ensure fresh build without using cached layers
$DOCKER_COMPOSE -f docker-compose-https.yml build --no-cache
$DOCKER_COMPOSE -f docker-compose-https.yml up -d
echo "" echo ""
echo "Step 4: Checking container status..." echo "Step 5: Checking container status..."
echo "----------------------------------------" echo "----------------------------------------"
# Wait a few seconds for containers to start # Wait a few seconds for containers to start
@ -76,9 +103,9 @@ echo "Deployment completed!"
echo "==========================================" echo "=========================================="
echo "" echo ""
echo "View logs command:" echo "View logs command:"
echo " docker-compose -f docker-compose-https.yml logs -f" echo " $DOCKER_COMPOSE -f docker-compose-https.yml logs -f"
echo "" echo ""
echo "Stop services command:" echo "Stop services command:"
echo " docker-compose -f docker-compose-https.yml down" echo " $DOCKER_COMPOSE -f docker-compose-https.yml down"
echo "" echo ""

Loading…
Cancel
Save