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