diff --git a/Dockerfile.prod b/Dockerfile.prod index c739cae..f414036 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -7,10 +7,11 @@ ENV PORT=3000 ENV HOSTNAME="0.0.0.0" RUN addgroup --system --gid 1001 nodejs && \ - adduser --system --uid 1001 nextjs + adduser --system --uid 1001 nextjs && \ + apk add --no-cache curl -COPY dist/standalone ./ -COPY dist/static ./dist/static +COPY dist/standalone/novalon-website/ ./ +COPY dist/static/ ./.next/static/ COPY public ./public RUN chown -R nextjs:nodejs /app diff --git a/docker-compose.server.yml b/docker-compose.server.yml index 286c0ee..e9d4703 100644 --- a/docker-compose.server.yml +++ b/docker-compose.server.yml @@ -18,19 +18,13 @@ services: - ./data:/app/data - ./uploads:/app/uploads healthcheck: - test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"] + test: ["CMD", "curl", "-f", "http://localhost:3000/api/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s - networks: - - novalon-network logging: driver: "json-file" options: max-size: "10m" max-file: "3" - -networks: - novalon-network: - external: true diff --git a/scripts/deploy-production.sh b/scripts/deploy-production.sh index f790f4e..82d77a4 100644 --- a/scripts/deploy-production.sh +++ b/scripts/deploy-production.sh @@ -16,7 +16,7 @@ echo "" echo "=== Step 1: 备份当前版本 ===" mkdir -p $BACKUP_DIR if [ -d "dist" ]; then - tar -czf $BACKUP_DIR/dist_$TIMESTAMP.tar.gz dist public package.json package-lock.json 2>/dev/null || echo "备份完成(部分文件可能不存在)" + tar -czf $BACKUP_DIR/dist_$TIMESTAMP.tar.gz dist public package.json package-lock.json Dockerfile.prod docker-compose.server.yml 2>/dev/null || echo "备份完成(部分文件可能不存在)" echo "✅ 备份已保存到: $BACKUP_DIR/dist_$TIMESTAMP.tar.gz" else echo "⚠️ 没有找到dist目录,跳过备份" @@ -48,7 +48,7 @@ sleep 10 echo "" echo "=== Step 6: 健康检查 ===" for i in {1..30}; do - if wget -q --spider http://localhost:3000/api/health 2>/dev/null; then + if curl -f http://localhost:3000/api/health >/dev/null 2>&1; then echo "✅ 健康检查通过!" echo "" @@ -75,7 +75,7 @@ if [ -f "$BACKUP_DIR/dist_$TIMESTAMP.tar.gz" ]; then docker-compose down docker-compose up -d sleep 10 - if wget -q --spider http://localhost:3000/api/health 2>/dev/null; then + if curl -f http://localhost:3000/api/health >/dev/null 2>&1; then echo "✅ 回滚成功" else echo "❌ 回滚也失败了!"