revert: 恢复 backup-service 和 mpc-service 原始 Dockerfile

回滚到纯 Alpine 版本(最初可用的版本)
- backup-service: 66199cc
- mpc-service: 6fa4d7a

之前的修改(slim/openssl/curl)导致问题

🤖 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 10:10:22 -08:00
parent 0388aee2d4
commit 781619e2ff
2 changed files with 21 additions and 46 deletions

View File

@ -1,13 +1,8 @@
# Stage 1: Build # Stage 1: Build
FROM node:20-slim AS builder FROM node:20-alpine AS builder
WORKDIR /app 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 files
COPY package*.json ./ COPY package*.json ./
COPY prisma ./prisma/ COPY prisma ./prisma/
@ -18,26 +13,20 @@ RUN npm ci
# Copy source code # Copy source code
COPY . . COPY . .
# Generate Prisma client (dummy DATABASE_URL for build time only) # Generate Prisma client
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate RUN npx prisma generate
# Build the application # Build the application
RUN npm run build RUN npm run build
# Stage 2: Production - use Debian slim for OpenSSL compatibility # Stage 2: Production
FROM node:20-slim AS production FROM node:20-alpine AS production
WORKDIR /app WORKDIR /app
# 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/*
# Create non-root user for security # Create non-root user for security
RUN groupadd -g 1001 nodejs && \ RUN addgroup -g 1001 -S nodejs && \
useradd -u 1001 -g nodejs nestjs adduser -S nestjs -u 1001
# Copy package files # Copy package files
COPY package*.json ./ COPY package*.json ./
@ -60,8 +49,8 @@ USER nestjs
EXPOSE 3002 EXPOSE 3002
# Health check # Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3002/health || exit 1 CMD wget --no-verbose --tries=1 --spider http://localhost:3002/health || exit 1
# Start the application # Start the application
CMD ["node", "dist/src/main.js"] CMD ["node", "dist/main.js"]

View File

@ -2,16 +2,11 @@
# MPC Party Service Dockerfile # MPC Party Service Dockerfile
# ============================================================================= # =============================================================================
# Build stage - use Debian slim for better Prisma compatibility # Build stage
FROM node:20-slim AS builder FROM node:20-alpine AS builder
WORKDIR /app 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 files
COPY package*.json ./ COPY package*.json ./
COPY tsconfig.json ./ COPY tsconfig.json ./
@ -21,8 +16,8 @@ COPY prisma ./prisma/
# Install dependencies # Install dependencies
RUN npm ci RUN npm ci
# Generate Prisma client (dummy DATABASE_URL for build time only) # Generate Prisma client
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate RUN npx prisma generate
# Copy source code # Copy source code
COPY src ./src COPY src ./src
@ -30,34 +25,25 @@ COPY src ./src
# Build TypeScript # Build TypeScript
RUN npm run build RUN npm run build
# Verify build output exists # Production stage
RUN ls -la dist/ && test -f dist/main.js FROM node:20-alpine
# Production stage - use Debian slim for OpenSSL compatibility
FROM node:20-slim
WORKDIR /app WORKDIR /app
# 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 # Install production dependencies only
COPY package*.json ./ COPY package*.json ./
RUN npm ci --only=production RUN npm ci --only=production
# Copy Prisma schema and generate client (dummy DATABASE_URL for build time only) # Copy Prisma schema and generate client
COPY prisma ./prisma/ COPY prisma ./prisma/
RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate RUN 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 groupadd -g 1001 nodejs && \ RUN addgroup -g 1001 -S nodejs && \
useradd -u 1001 -g nodejs nestjs adduser -S nestjs -u 1001
# 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
@ -70,7 +56,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 curl -f http://localhost:3006/api/v1/health || exit 1 CMD node -e "require('http').get('http://localhost:3006/api/v1/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
# Start service # Start service
CMD ["node", "dist/main.js"] CMD ["node", "dist/main.js"]