Files
webshop/Dockerfile
DanielS e1a555d4f9
Some checks failed
Staging Build / build (push) Failing after 1m30s
Fix duplicate next.config copy in Dockerfile
2026-06-22 23:29:29 +02:00

49 lines
1.3 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Use a multistage build for a Next.js app
# ---------- Builder stage ----------
FROM node:20-alpine AS builder
# Set working directory
WORKDIR /app
# Install dependencies (use package lock when present)
COPY shop/package*.json ./
RUN npm ci --omit=dev
# Copy the source code
COPY shop/ .
# Build the production output
RUN npm run build
# ---------- Runtime stage ----------
FROM node:20-alpine AS runner
WORKDIR /app
# Copy only built assets and runtime dependencies
COPY --from=builder /app/.next ./.next
# KORREKTUR: Kopiert den public-Ordner nur, wenn er wirklich existiert
COPY --from=builder /app/public* ./public
COPY --from=builder /app/package*.json ./
# KORREKTUR: Flexibles Kopieren der Next-Konfiguration (egal ob .js oder .mjs)
COPY --from=builder /app/next.config.* ./
# Optionale TS-Dateien (nur kopieren, wenn vorhanden, blockiert den Build nicht mehr)
COPY --from=builder /app/tsconfig.json ./ 2>/dev/null || true
COPY --from=builder /app/next-env.d.ts ./ 2>/dev/null || true
COPY --from=builder /app/tsconfig.json ./ 2>/dev/null || true
COPY --from=builder /app/next-env.d.ts ./ 2>/dev/null || true
# Install production dependencies (already installed in builder, but ensure they are present)
RUN npm ci --omit=dev
# Environment variables
ENV NODE_ENV=production
ENV PORT=3000
EXPOSE 3000
# Start the Next.js server
CMD ["npm", "run", "start"]