mirror of
http://172.20.10.11:3000/gitadmin/INSIGHT-MVP.git
synced 2026-06-25 01:16:40 +02:00
bcrypt requires native compilation which was skipped by --ignore-scripts. Added python3/make/g++ and npm rebuild bcrypt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
67 lines
1.7 KiB
Docker
67 lines
1.7 KiB
Docker
# ============================================================
|
|
# INSIGHT Core-Service - Multi-Stage Dockerfile
|
|
# ============================================================
|
|
|
|
# --- Base Stage ---
|
|
FROM node:20-alpine AS base
|
|
WORKDIR /app
|
|
RUN apk add --no-cache openssl
|
|
|
|
# --- Dependencies Stage ---
|
|
FROM base AS deps
|
|
# Build-Tools fuer native Module (bcrypt)
|
|
RUN apk add --no-cache python3 make g++
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci --ignore-scripts
|
|
# Native Module kompilieren (bcrypt)
|
|
RUN npm rebuild bcrypt
|
|
# Prisma Generate braucht die Schema-Dateien
|
|
COPY prisma ./prisma
|
|
RUN npx prisma generate --schema=prisma/core.schema.prisma
|
|
|
|
# --- Development Stage ---
|
|
FROM base AS development
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
RUN npx prisma generate --schema=prisma/core.schema.prisma
|
|
EXPOSE 3000
|
|
CMD ["npm", "run", "start:dev"]
|
|
|
|
# --- Build Stage ---
|
|
FROM base AS build
|
|
WORKDIR /app
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# --- Production Stage ---
|
|
FROM base AS production
|
|
WORKDIR /app
|
|
ENV NODE_ENV=production
|
|
|
|
# Build-Tools fuer native Module (bcrypt)
|
|
RUN apk add --no-cache python3 make g++
|
|
|
|
# Nur Produktions-Dependencies
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci --omit=dev --ignore-scripts
|
|
RUN npm rebuild bcrypt
|
|
|
|
# Build-Tools entfernen (Image klein halten)
|
|
RUN apk del python3 make g++
|
|
|
|
# Prisma Client generieren
|
|
COPY prisma ./prisma
|
|
RUN npx prisma generate --schema=prisma/core.schema.prisma
|
|
|
|
# Kompilierter Code
|
|
COPY --from=build /app/dist ./dist
|
|
|
|
# Non-root User
|
|
RUN addgroup -g 1001 -S nodejs && \
|
|
adduser -S nestjs -u 1001 -G nodejs
|
|
USER nestjs
|
|
|
|
EXPOSE 3000
|
|
CMD ["node", "dist/main"]
|