add dockerfile
This commit is contained in:
55
dockerfile
Normal file
55
dockerfile
Normal file
@@ -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"]
|
||||||
Reference in New Issue
Block a user