Files
datacat/Dockerfile
CatoandClaude Opus 5 d88da54244 refactor(blog): bip-kit typed blocks replace contentlayer — the post body is server-rendered again (#254)
contentlayer generated a typed `.contentlayer/generated` package at
install/build time and compiled each post's MDX into a JS function. That
indirection had already cost this app a working blog: contentlayer 0.3.x
calls a React internal (`getOwner`) that React 19 removed, so the compiled
body crashed during prerender AND during SSR. The workaround shipped in
MDXContentClient.tsx was to render the post body client-only
(`next/dynamic`, `ssr: false`) — every reader and every crawler got
"Lade Inhalt…" and the article appeared only after hydration.

Posts are now markdown read from disk and parsed with bip-kit 0.2.2:

- content/blog/intake-engine.mdx → .md. The `<Callout type="tip">` became
  GitHub callout syntax (`> [!TIP]`), the `<Infographic>` a captioned
  figure, and the MDX `import` line is gone. `&nbsp;` became a real U+00A0,
  since typed blocks have no HTML passthrough to render an entity through.
  Word-level parity verified: zero words lost, and the article parses to the
  28 blocks you would expect (callout, figure, ol, table, hr, …).
- src/lib/blog.ts is the collection: parseFrontmatter + parseContentBlocks +
  extractToc + readingTime. It enforces the `title`/`date` requirement that
  contentlayer's field schema used to, and guards the slug before it reaches
  the filesystem.
- /blog/[slug] renders through bip-kit's async server ArticleBody. The route
  is prerendered (SSG) again instead of being a client-only shell, and it
  gains a scroll-spy TOC, a reading-progress hairline, server-side shiki
  highlighting, figure lightbox and reading time.
- /blog is a server component again: as a client component it shipped its
  own list-and-sort to every reader for data that comes off disk.
- setHighlighterLoader(() => import('shiki')) is registered at module scope
  because this app builds `output: standalone`, where bip-kit's zero-config
  shiki import is invisible to Next's file tracer — without the literal,
  production would ship unhighlighted while dev looked right.

Deleted with it: contentlayer, next-contentlayer, rehype-pretty-code,
remark-gfm, @mdx-js/react; contentlayer.config.ts; MDXContent.tsx,
MDXContentClient.tsx, MDXComponents.tsx; `withContentlayer` in next.config;
the `contentlayer:build` script, the `postinstall` hook that ran it, and
the SKIP_CONTENTLAYER seams in both Dockerfiles and deploy.yml.disabled that
existed only to switch that build off; the `.contentlayer` entries in
.gitignore/.prettierignore/eslint ignores; and the
estree-util-value-to-estree + toml overrides, which pinned packages nothing
depends on any more (deepmerge-ts stays — it comes via @prisma/config).

Security: contentlayer was the only path to @opentelemetry/core and
@opentelemetry/sdk-trace-node. `pnpm audit` in frontend/ goes from
"2 vulnerabilities found — 1 moderate | 1 high" to "No known
vulnerabilities found".

Visible: the article carried `prose prose-indigo dark:prose-invert` with no
@tailwindcss/typography plugin installed, so those classes matched nothing
and the post rendered as unstyled browser defaults. src/app/blog/blog.css
maps datacat's palette onto bip-kit's --bp-* contract for BOTH themes —
datacat's dark mode is prefers-color-scheme, the same axis bip-kit switches
on, so the article now darkens with the page instead of ignoring it.

Only frontend/ is touched; backend/ is untouched.


Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 14:55:47 +00:00

80 lines
2.4 KiB
Docker

# Multi-stage Dockerfile for Formular Universal AI-Powered Form Intelligence Platform
# Stage 1: Base Node.js image
# node:24 — pnpm 11 needs Node >= 22.13, and 24 is the fleet default.
FROM node:24-alpine AS base
WORKDIR /app
RUN apk add --no-cache libc6-compat
# corepack reads the packageManager pin from package.json
RUN corepack enable pnpm
# Stage 2: Dependencies installer
FROM base AS deps
COPY package.json pnpm-lock.yaml ./
COPY frontend/package.json frontend/pnpm-lock.yaml frontend/pnpm-workspace.yaml ./frontend/
COPY backend/package.json backend/pnpm-lock.yaml backend/pnpm-workspace.yaml ./backend/
RUN pnpm install --frozen-lockfile
RUN cd frontend && pnpm install --frozen-lockfile
RUN cd backend && pnpm install --frozen-lockfile
# Stage 3: Frontend builder
FROM base AS frontend-builder
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/frontend/node_modules ./frontend/node_modules
COPY frontend ./frontend
COPY package.json pnpm-lock.yaml ./
# Build frontend
WORKDIR /app/frontend
RUN pnpm run build
# Stage 4: Backend builder
FROM base AS backend-builder
COPY --from=deps /app/backend/node_modules ./backend/node_modules
COPY backend ./backend
COPY package.json pnpm-lock.yaml ./
# Generate Prisma client
WORKDIR /app/backend
RUN pnpm exec prisma generate
# Stage 5: Production runner
FROM node:24-alpine AS runner
WORKDIR /app
# Install production dependencies
RUN apk add --no-cache postgresql-client
RUN corepack enable pnpm
# Create non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
# Copy built applications
COPY --from=frontend-builder --chown=nextjs:nodejs /app/frontend/.next ./frontend/.next
COPY --from=frontend-builder --chown=nextjs:nodejs /app/frontend/public ./frontend/public
COPY --from=frontend-builder /app/frontend/package.json ./frontend/
COPY --from=backend-builder /app/backend ./backend
COPY --from=deps /app/frontend/node_modules ./frontend/node_modules
COPY --from=deps /app/backend/node_modules ./backend/node_modules
# Copy root package.json for scripts
COPY package.json pnpm-lock.yaml ./
# Set environment variables
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
# Expose ports
EXPOSE 3000 5001
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:5001/health || exit 1
# Switch to non-root user
USER nextjs
# Start application
CMD ["pnpm", "run", "start"]