|
Hi! I am testing out fumadocs for our internal documentation site. Currently, I have everything configured so that the documentation works as expected in dev mode. But when I try to package it into a Docker image, the content seems to be missing, even though it is present in the final image, it is not served by the server. Here is my Dockerfile: FROM node:22-alpine AS base
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
# source.config.ts must be present due to fumadocs-mdx dependency
COPY package.json yarn.lock* .npmrc* source.config.ts ./
RUN yarn install --frozen-lockfile
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN yarn 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
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=builder --chown=nextjs:nodejs /app/.source ./.source
COPY --from=builder --chown=nextjs:nodejs /app/.content-collections ./.content-collections
USER nextjs
EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]The docs are located in the content/docs folder which is copied over to the container before doing next.config.mjs import { createMDX } from 'fumadocs-mdx/next';
const withMDX = createMDX();
/** @type {import('next').NextConfig} */
const config = {
output: 'standalone',
reactStrictMode: true,
};
export default withMDX(config);source.config.ts import { defineDocs, defineConfig } from 'fumadocs-mdx/config';
export const { docs, meta } = defineDocs({
dir: 'content/docs',
});
export default defineConfig();lib/source.ts import { docs, meta } from '../../.source';
import { createMDXSource } from 'fumadocs-mdx';
import { loader } from 'fumadocs-core/source';
import { createElement } from 'react';
import { icons } from 'lucide-react';
export const source = loader({
baseUrl: '/docs',
rootDir: 'content/docs',
source: createMDXSource(docs, meta),
icon(icon) {
if (!icon) {
return;
}
if (icon in icons) {
return createElement(icons[icon as keyof typeof icons], {
color: '#2fa6d1'
});
}
}
});Any help would be appreciated. |
Replies: 2 comments 3 replies
|
Just a heads up, I haven't found any Dockerfile examples in Fumadocs' docs. If it exists I would be happy to read it :) |
|
Okay so I somehow debugged it, looks like this was my problem: source.ts import { docs, meta } from '../../.source';
import { createMDXSource } from 'fumadocs-mdx';
import { loader } from 'fumadocs-core/source';
import { createElement } from 'react';
import { icons } from 'lucide-react';
export const source = loader({
baseUrl: '/docs',
- rootDir: 'content/docs',
+
source: createMDXSource(docs, meta),
icon(icon) {
if (!icon) {
return;
}
if (icon in icons) {
return createElement(icons[icon as keyof typeof icons], {
color: '#2fa6d1'
});
}
}
}); |
Hmm interesting, we have removed the usage of
rootDirin code examples from our docs long time ago to avoid confusion between the dir option insource.config.ts, it is only existing for backward compatibility.