- z.any() replaced with z.record(z.string()) on webhook headers
- availabilityJson typed with z.array(z.object({ start, end }))
- Frontend webhook headers converted from array to Record before API call
- Docker HEALTHCHECK added to Dockerfile (health endpoint already existed)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
77 lines
2.2 KiB
Docker
77 lines
2.2 KiB
Docker
# =============================================================================
|
|
# MOPC Platform - Production Dockerfile
|
|
# =============================================================================
|
|
# Multi-stage build for optimized production image
|
|
|
|
FROM node:22-alpine AS base
|
|
|
|
# Install dependencies only when needed
|
|
FROM base AS deps
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json* .npmrc* ./
|
|
RUN npm ci
|
|
|
|
# Rebuild the source code only when needed
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# Generate Prisma client
|
|
RUN npx prisma generate
|
|
|
|
# Build Next.js — mount .next/cache as a Docker build cache for faster rebuilds
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
RUN --mount=type=cache,target=/app/.next/cache npm run build
|
|
|
|
# Production image, copy all the files and run next
|
|
FROM base AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# Create non-root user for security
|
|
RUN addgroup --system --gid 1001 nodejs
|
|
RUN adduser --system --uid 1001 nextjs
|
|
|
|
# Install runtime dependencies for migrations and seeding
|
|
RUN apk add --no-cache libc6-compat
|
|
|
|
# Copy built Next.js standalone output
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder /app/.next/standalone ./
|
|
COPY --from=builder /app/.next/static ./.next/static
|
|
|
|
# Copy full node_modules for prisma migrations and seeding
|
|
COPY --from=builder /app/node_modules ./node_modules
|
|
COPY --from=builder /app/prisma ./prisma
|
|
COPY --from=builder /app/package.json ./package.json
|
|
|
|
# Copy files needed for seeding (tsx needs tsconfig for path resolution)
|
|
COPY --from=builder /app/docs/Candidatures2026.csv ./docs/Candidatures2026.csv
|
|
COPY --from=builder /app/tsconfig.json ./tsconfig.json
|
|
|
|
# Copy entrypoint script
|
|
COPY docker/docker-entrypoint.sh /app/docker-entrypoint.sh
|
|
RUN chmod +x /app/docker-entrypoint.sh
|
|
|
|
# Set correct permissions
|
|
RUN chown -R nextjs:nodejs /app
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 7600
|
|
|
|
ENV PORT=7600
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
|
CMD wget -qO- http://localhost:7600/api/health || exit 1
|
|
|
|
# Run via entrypoint (migrate then start)
|
|
CMD ["/app/docker-entrypoint.sh"]
|