fix: 修复多个服务的 Docker 健康检查和构建配置
identity-service: - 修复 HEALTHCHECK URL: /health → /api/v1/health wallet-service: - 修复 HEALTHCHECK URL: /health → /api/v1/health leaderboard-service: - 修复端口: 3000 → 3007 - 添加 HEALTHCHECK (/api/health) - 添加非 root 用户 (nestjs) - 添加 NODE_ENV=production mpc-service: - builder 阶段从 alpine 改为 slim (解决 Prisma 兼容性) - 添加 OpenSSL 依赖到 builder 阶段 - 添加 wget 依赖 - HEALTHCHECK 从 node 脚本改为 wget 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
4bd25d4e3c
commit
451185005f
|
|
@ -66,7 +66,7 @@ EXPOSE 3000
|
||||||
|
|
||||||
# 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 wget -q --spider http://localhost:3000/health || exit 1
|
CMD wget -q --spider http://localhost:3000/api/v1/health || exit 1
|
||||||
|
|
||||||
# Start service
|
# Start service
|
||||||
CMD ["node", "dist/src/main.js"]
|
CMD ["node", "dist/src/main.js"]
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,21 @@ RUN DATABASE_URL="postgresql://user:pass@localhost:5432/db" npx prisma generate
|
||||||
# Copy built application
|
# Copy built application
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
|
|
||||||
|
# Create non-root user
|
||||||
|
RUN groupadd -g 1001 nodejs && \
|
||||||
|
useradd -u 1001 -g nodejs nestjs
|
||||||
|
|
||||||
|
# Switch to non-root user
|
||||||
|
USER nestjs
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
# Expose port
|
# Expose port
|
||||||
EXPOSE 3000
|
EXPOSE 3007
|
||||||
|
|
||||||
|
# Health check
|
||||||
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
|
||||||
|
CMD wget -q --spider http://localhost:3007/api/health || exit 1
|
||||||
|
|
||||||
# Start the application
|
# Start the application
|
||||||
CMD ["node", "dist/src/main.js"]
|
CMD ["node", "dist/src/main.js"]
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,16 @@
|
||||||
# MPC Party Service Dockerfile
|
# MPC Party Service Dockerfile
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
# Build stage
|
# Build stage - use Debian slim for better Prisma compatibility
|
||||||
FROM node:20-alpine AS builder
|
FROM node:20-slim 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 ./
|
||||||
|
|
@ -33,9 +38,10 @@ FROM node:20-slim
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install OpenSSL
|
# Install OpenSSL and wget for health checks
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
openssl \
|
openssl \
|
||||||
|
wget \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install production dependencies only
|
# Install production dependencies only
|
||||||
|
|
@ -64,7 +70,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 wget -q --spider http://localhost:3006/api/v1/health || exit 1
|
||||||
|
|
||||||
# Start service
|
# Start service
|
||||||
CMD ["node", "dist/main.js"]
|
CMD ["node", "dist/main.js"]
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ EXPOSE 3001
|
||||||
|
|
||||||
# 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 wget -q --spider http://localhost:3001/health || exit 1
|
CMD wget -q --spider http://localhost:3001/api/v1/health || exit 1
|
||||||
|
|
||||||
# Start service
|
# Start service
|
||||||
CMD ["node", "dist/main.js"]
|
CMD ["node", "dist/main.js"]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue