Files
Lageplan/Dockerfile
Pepe Ziberi bae5a36492
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 32m35s
perf(ci): Build-Zeit senken – BuildKit-Cache-Mounts + mode=min
- Dockerfile: --mount=type=cache für /root/.npm (npm ci) und /app/.next/cache
  (inkrementeller next build statt jedes Mal von Null)
- deploy.yml: cache-to mode=max -> mode=min (spart auf dem NAS den ~12 Min
  Cache-Export, der bisher grösster Einzelposten war)
- provenance/sbom aus (weniger Attestation-Export)
- ENV-Legacy-Warnungen behoben (ENV key=value)
- Version 1.4.5

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 22:30:42 +02:00

72 lines
2.8 KiB
Docker

# syntax=docker/dockerfile:1
# Stage 1: Dependencies
FROM node:20-alpine AS deps
RUN apk add --no-cache libc6-compat openssl
WORKDIR /app
COPY package.json package-lock.json* ./
# npm-Cache über BuildKit persistent halten (schnellere Re-Installs)
RUN --mount=type=cache,target=/root/.npm npm ci --ignore-scripts --legacy-peer-deps
# Stage 2: Builder
FROM node:20-alpine AS builder
RUN apk add --no-cache openssl
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Generate Prisma Client
RUN npx prisma generate
# Copy docker-specific env for build (DATABASE_URL pointing to 'db' service)
COPY .env.docker .env
# Build Next.js
ENV NEXT_TELEMETRY_DISABLED=1
# .next/cache über BuildKit persistent halten → inkrementeller Build statt jedes Mal von Null
RUN --mount=type=cache,target=/app/.next/cache npm run build
# Stage 3: Runner
FROM node:20-alpine AS runner
RUN apk add --no-cache openssl
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
WORKDIR /app
# Fast: only chown the /app directory itself, not recursively
RUN chown nextjs:nodejs /app
USER nextjs
# Install only the unbundled runtime deps needed by the custom server.
# Running as USER nextjs means files are already correctly owned — no slow chown -R needed afterwards.
RUN npm install --omit=dev --legacy-peer-deps socket.io@4.7.4 @react-pdf/renderer@4.3.2 qrcode@1.5.4 --no-save
COPY --chown=nextjs:nodejs --from=builder /app/.next/standalone ./
COPY --chown=nextjs:nodejs --from=builder /app/.next/static ./.next/static
# Ensure all public files (videos, images, etc.) are present in the runtime image
COPY --chown=nextjs:nodejs --from=builder /app/public ./public
COPY --chown=nextjs:nodejs --from=builder /app/.env ./.env
COPY --chown=nextjs:nodejs --from=builder /app/prisma ./prisma
COPY --chown=nextjs:nodejs --from=builder /app/node_modules/.prisma ./node_modules/.prisma
COPY --chown=nextjs:nodejs --from=builder /app/node_modules/prisma ./node_modules/prisma
COPY --chown=nextjs:nodejs --from=builder /app/node_modules/@prisma ./node_modules/@prisma
COPY --chown=nextjs:nodejs --from=builder /app/node_modules/bcryptjs ./node_modules/bcryptjs
COPY --chown=nextjs:nodejs --from=builder /app/node_modules/stripe ./node_modules/stripe
COPY --chown=nextjs:nodejs --from=builder /app/node_modules/next ./node_modules/next
COPY --chown=nextjs:nodejs --from=builder /app/node_modules/react ./node_modules/react
COPY --chown=nextjs:nodejs --from=builder /app/node_modules/react-dom ./node_modules/react-dom
COPY --chown=nextjs:nodejs --from=builder /app/package.json ./package.json
COPY --chown=nextjs:nodejs server-custom.js ./server-custom.js
COPY --chown=nextjs:nodejs docker-entrypoint.sh ./docker-entrypoint.sh
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["sh", "docker-entrypoint.sh"]