部署
部署你的 Fumadocs 应用
概览
🌐 Overview
你的 Fumadocs 应用是基于底层的 React 框架(例如 Next.js)构建的,你需要查看所用 React 框架的相关文档以获取部署指南。
🌐 Your Fumadocs app is powered by the underlying React framework (e.g. Next.js), you will need to check the relevant docs of your React framework for deployment guides.
如果你希望将应用作为 SPA 应用(完全静态,可在 CDN 上托管)进行托管,请参阅 静态构建。
🌐 If you are looking to host the app as a SPA app (fully static, hostable on CDN), see Static Build.
关于特定组合有一些额外说明:
🌐 There's some extra notes on specific combinations:
Next.js + Cloudflare
请使用 https://opennext.js.org/cloudflare,Fumadocs 在 Edge 运行时无法使用。
🌐 Use https://opennext.js.org/cloudflare, Fumadocs doesn't work on Edge runtime.
Next.js + Docker
如果你想使用 Docker 部署你的 Fumadocs 应用,并且 配置了 Fumadocs MDX,请确保在 Dockerfile 中将 source.config.ts 文件和你的 next.config.js 文件添加到 WORKDIR。以下片段摘自官方的 Next.js Dockerfile 示例:
🌐 If you want to deploy your Fumadocs app using Docker with Fumadocs MDX configured, make sure to add the source.config.ts file and your next.config.js file to the WORKDIR in the Dockerfile.
The following snippet is taken from the official Next.js Dockerfile Example:
# syntax=docker.io/docker/dockerfile:1
FROM node:18-alpine AS base
# Install dependencies only when needed
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
# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* source.config.ts next.config.* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://next.nodejs.cn/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED=1
RUN \
if [ -f yarn.lock ]; then yarn run build; \
elif [ -f package-lock.json ]; then npm run build; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi
# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
# 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://next.nodejs.cn/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
USER nextjs
EXPOSE 3000
ENV PORT=3000
# server.js is created by next build from the standalone output
# https://next.nodejs.cn/docs/pages/api-reference/config/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]这确保了 Fumadocs MDX 在构建过程中可以访问你的配置文件。
🌐 This ensures Fumadocs MDX can access your configuration file during builds.
Last updated on
