fix(reporting-service): 修复 Dockerfile 构建和健康检查

- 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 <noreply@anthropic.com>
This commit is contained in:
Developer 2025-12-02 07:44:36 -08:00
parent 86e7d5a3fa
commit 8fe4f651dc
1 changed files with 13 additions and 3 deletions

View File

@ -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"]