From 4051c40960e50c08a0a0ecd3ca868da6669975bf Mon Sep 17 00:00:00 2001 From: robin Date: Thu, 18 Dec 2025 17:31:48 +0100 Subject: [PATCH] add dockerfile --- dockerfile | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 dockerfile diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..9726c1f --- /dev/null +++ b/dockerfile @@ -0,0 +1,55 @@ +# 1. Base Image +FROM node:20-alpine AS base + +# Corepack aktivieren, um pnpm bereitzustellen (kein npm install -g pnpm nötig) +RUN corepack enable && corepack prepare pnpm@latest --activate + +# 2. Dependencies Stage +FROM base AS deps +# libc6-compat wird oft für Alpine benötigt +RUN apk add --no-cache libc6-compat +WORKDIR /app + +# Kopiere package.json und pnpm-lock.yaml +COPY package.json pnpm-lock.yaml ./ + +# Installiere Abhängigkeiten mit pnpm +RUN pnpm install --frozen-lockfile + +# 3. Builder Stage +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Telemetry deaktivieren (optional) +ENV NEXT_TELEMETRY_DISABLED 1 + +# Build ausführen +RUN pnpm run build + +# 4. Runner Stage (Production Image) +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV production +ENV NEXT_TELEMETRY_DISABLED 1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +# Kopiere Public Assets +COPY --from=builder /app/public ./public + +# Kopiere Standalone Build (benötigt output: 'standalone' in next.config.js) +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +# WICHTIG: Port auf 7777 ändern +EXPOSE 7777 +ENV PORT 7777 +ENV HOSTNAME "0.0.0.0" + +CMD ["node", "server.js"] \ No newline at end of file