fix(mpc-service): 改用 Debian slim 基础镜像

- 从 Alpine 改为 Debian slim (与 identity-service 一致)
- 使用 curl 进行健康检查
- 添加 DATABASE_URL 用于 Prisma generate
- 通过代理访问官方源

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Developer 2025-12-03 19:57:11 -08:00
parent e4172c11b9
commit 55d40c8200
1 changed files with 15 additions and 9 deletions

View File

@ -2,7 +2,7 @@
# MPC Party Service Dockerfile
# =============================================================================
# Build stage
# Build stage - use Alpine for smaller build context
FROM node:20-alpine AS builder
WORKDIR /app
@ -25,13 +25,19 @@ COPY src ./src
# Build TypeScript
RUN npm run build
# Production stage
FROM node:20-alpine
# Verify build output exists
RUN ls -la dist/ && test -f dist/main.js
# Production stage - use Debian slim for OpenSSL compatibility
FROM node:20-slim
WORKDIR /app
# Install OpenSSL for Prisma (Alpine 3.22 uses OpenSSL 3)
RUN apk add --no-cache openssl
# Install OpenSSL and curl for health checks
RUN apt-get update && apt-get install -y --no-install-recommends \
openssl \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install production dependencies only
COPY package*.json ./
@ -39,14 +45,14 @@ RUN npm ci --only=production
# Copy Prisma schema and generate client
COPY prisma ./prisma/
RUN npx prisma generate
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
# Copy built files
COPY --from=builder /app/dist ./dist
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nestjs -u 1001
RUN groupadd -g 1001 nodejs && \
useradd -u 1001 -g nodejs nestjs
# Create temp directory for TSS
RUN mkdir -p /tmp/tss && chown -R nestjs:nodejs /tmp/tss
@ -59,7 +65,7 @@ EXPOSE 3006
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD node -e "require('http').get('http://localhost:3006/api/v1/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
CMD curl -f http://localhost:3006/api/v1/health || exit 1
# Start service
CMD ["node", "dist/main.js"]