Files
Patrick Plate f6a7143d1b
Deploy to Production / test (push) Has been cancelled
Deploy to Production / deploy (push) Has been cancelled
fix(frontend): guard metadataBase against undefined BASE_URL
Root cause of the SSG/page-data build crash: src/app/layout.tsx evaluated
new URL(process.env.BASE_URL) at module load. BASE_URL was never set as a
build-time ENV, so it was undefined -> ERR_INVALID_URL, input: 'undefined'.
Because this is the root layout, its metadata is collected for every route,
explaining why both /impressum (marketing) and /portal-login (non-marketing)
failed identically. The earlier NextAuth/middleware/force-dynamic fixes could
not help because metadata evaluation happens before any of that.

- layout.tsx: fall back to http://localhost:3000 when BASE_URL is unset
- Dockerfile: add BASE_URL build-time placeholder (matches AUTH_URL pattern)
2026-06-13 09:44:21 +02:00

46 lines
1.2 KiB
Docker

FROM node:22-alpine AS base
RUN corepack enable && corepack prepare pnpm@10.8.1 --activate
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
# Hardcoded build-time placeholders — NextAuth v5 reads AUTH_URL at module init time.
# Real values are injected at runtime via docker-compose environment.
ENV AUTH_URL=http://localhost:3000
ENV NEXTAUTH_URL=http://localhost:3000
ENV AUTH_SECRET=build-time-placeholder-secret-minimum-32-characters
ENV NEXTAUTH_SECRET=build-time-placeholder-secret-minimum-32-characters
ENV AUTH_TRUST_HOST=1
ENV BACKEND_URL=http://localhost:8080
ENV BASE_URL=http://localhost:3000
RUN pnpm build
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
COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]