From 8fe4f651dcf422a8dfd2a33171ecaeebb491842a Mon Sep 17 00:00:00 2001 From: Developer Date: Tue, 2 Dec 2025 07:44:36 -0800 Subject: [PATCH] =?UTF-8?q?fix(reporting-service):=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?Dockerfile=20=E6=9E=84=E5=BB=BA=E5=92=8C=E5=81=A5=E5=BA=B7?= =?UTF-8?q?=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - builder 阶段从 alpine 改为 slim (解决 Prisma 兼容性) - 添加 OpenSSL 依赖到 builder 阶段 - 添加构建验证步骤 - 修复健康检查 URL: /health → /api/v1/health - 添加 NODE_ENV=production 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- backend/services/reporting-service/Dockerfile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/services/reporting-service/Dockerfile b/backend/services/reporting-service/Dockerfile index 919b641e..5fbcffd1 100644 --- a/backend/services/reporting-service/Dockerfile +++ b/backend/services/reporting-service/Dockerfile @@ -2,11 +2,16 @@ # Reporting Service Dockerfile # ============================================================================= -# Build stage -FROM node:20-alpine AS builder +# Build stage - use Debian slim for better Prisma compatibility +FROM node:20-slim AS builder WORKDIR /app +# Install OpenSSL for Prisma +RUN apt-get update && apt-get install -y --no-install-recommends \ + openssl \ + && rm -rf /var/lib/apt/lists/* + # Copy package files COPY package*.json ./ COPY tsconfig*.json ./ @@ -27,6 +32,9 @@ COPY src ./src # Build TypeScript RUN npm run build +# Verify build output exists +RUN ls -la dist/src/ && test -f dist/src/main.js + # Production stage - use Debian slim for OpenSSL compatibility FROM node:20-slim @@ -56,12 +64,14 @@ RUN groupadd -g 1001 nodejs && \ # Switch to non-root user USER nestjs +ENV NODE_ENV=production + # Expose port EXPOSE 3008 # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \ - CMD wget -q --spider http://localhost:3008/health || exit 1 + CMD wget -q --spider http://localhost:3008/api/v1/health || exit 1 # Start service CMD ["node", "dist/src/main.js"]