Merge remote-tracking branch 'origin/main' into cloudflare
This commit is contained in:
commit
0164c833db
13
.dockerignore
Normal file
13
.dockerignore
Normal file
@ -0,0 +1,13 @@
|
||||
.cursor
|
||||
.github
|
||||
.next
|
||||
.open-next
|
||||
.source
|
||||
.vscode
|
||||
.git
|
||||
.wrangler
|
||||
.dockerignore
|
||||
node_modules
|
||||
**/node_modules
|
||||
Dockerfile
|
||||
LICENSE
|
62
Dockerfile
Normal file
62
Dockerfile
Normal file
@ -0,0 +1,62 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM node:20-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
|
||||
COPY package.json pnpm-lock.yaml* ./
|
||||
# Copy config files needed for fumadocs-mdx postinstall
|
||||
COPY source.config.ts ./
|
||||
COPY content ./content
|
||||
RUN npm install -g pnpm && pnpm i --frozen-lockfile
|
||||
|
||||
# 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://nextjs.org/telemetry
|
||||
# Uncomment the following line in case you want to disable telemetry during the build.
|
||||
# ENV NEXT_TELEMETRY_DISABLED 1
|
||||
|
||||
RUN npm install -g pnpm \
|
||||
&& DOCKER_BUILD=true pnpm build
|
||||
|
||||
# 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
|
||||
|
||||
# Set the correct permission for prerender cache
|
||||
RUN mkdir .next
|
||||
RUN chown nextjs:nodejs .next
|
||||
|
||||
# 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
|
||||
|
||||
USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
|
||||
# server.js is created by next build from the standalone output
|
||||
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
|
||||
CMD ["node", "server.js"]
|
@ -6,6 +6,9 @@ import createNextIntlPlugin from 'next-intl/plugin';
|
||||
* https://nextjs.org/docs/app/api-reference/config/next-config-js
|
||||
*/
|
||||
const nextConfig: NextConfig = {
|
||||
// Docker standalone output
|
||||
...(process.env.DOCKER_BUILD === 'true' && { output: 'standalone' }),
|
||||
|
||||
/* config options here */
|
||||
devIndicators: false,
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { CustomPage } from '@/components/page/custom-page';
|
||||
import { pagesSource } from '@/lib/docs/source';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { pagesSource } from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import type { NextPageProps } from '@/types/next-page-props';
|
||||
import type { Metadata } from 'next';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { CustomPage } from '@/components/page/custom-page';
|
||||
import { pagesSource } from '@/lib/docs/source';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { pagesSource } from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import type { NextPageProps } from '@/types/next-page-props';
|
||||
import type { Metadata } from 'next';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { CustomPage } from '@/components/page/custom-page';
|
||||
import { pagesSource } from '@/lib/docs/source';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { pagesSource } from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import type { NextPageProps } from '@/types/next-page-props';
|
||||
import type { Metadata } from 'next';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ReleaseCard } from '@/components/changelog/release-card';
|
||||
import Container from '@/components/layout/container';
|
||||
import { changelogSource } from '@/lib/docs/source';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { changelogSource } from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import type { NextPageProps } from '@/types/next-page-props';
|
||||
import type { Metadata } from 'next';
|
||||
|
@ -1,8 +1,8 @@
|
||||
import BlogGridWithPagination from '@/components/blog/blog-grid-with-pagination';
|
||||
import { websiteConfig } from '@/config/website';
|
||||
import { LOCALES } from '@/i18n/routing';
|
||||
import { blogSource, categorySource } from '@/lib/docs/source';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { blogSource, categorySource } from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import type { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
@ -1,8 +1,8 @@
|
||||
import BlogGridWithPagination from '@/components/blog/blog-grid-with-pagination';
|
||||
import { websiteConfig } from '@/config/website';
|
||||
import { LOCALES } from '@/i18n/routing';
|
||||
import { blogSource, categorySource } from '@/lib/docs/source';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { blogSource, categorySource } from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import type { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { BlogCategoryFilter } from '@/components/blog/blog-category-filter';
|
||||
import Container from '@/components/layout/container';
|
||||
import { categorySource } from '@/lib/docs/source';
|
||||
import { categorySource } from '@/lib/source';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
import BlogGridWithPagination from '@/components/blog/blog-grid-with-pagination';
|
||||
import { websiteConfig } from '@/config/website';
|
||||
import { LOCALES } from '@/i18n/routing';
|
||||
import { blogSource } from '@/lib/docs/source';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { blogSource } from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import type { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
@ -1,8 +1,8 @@
|
||||
import BlogGridWithPagination from '@/components/blog/blog-grid-with-pagination';
|
||||
import { websiteConfig } from '@/config/website';
|
||||
import { LOCALES } from '@/i18n/routing';
|
||||
import { blogSource } from '@/lib/docs/source';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { blogSource } from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import type { Locale } from 'next-intl';
|
||||
import { getTranslations } from 'next-intl/server';
|
||||
|
@ -1,17 +1,17 @@
|
||||
import AllPostsButton from '@/components/blog/all-posts-button';
|
||||
import BlogGrid from '@/components/blog/blog-grid';
|
||||
import { getMDXComponents } from '@/components/custom/mdx-components';
|
||||
import { getMDXComponents } from '@/components/docs/mdx-components';
|
||||
import { NewsletterCard } from '@/components/newsletter/newsletter-card';
|
||||
import { websiteConfig } from '@/config/website';
|
||||
import { LocaleLink } from '@/i18n/navigation';
|
||||
import { formatDate } from '@/lib/formatter';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import {
|
||||
type BlogType,
|
||||
authorSource,
|
||||
blogSource,
|
||||
categorySource,
|
||||
} from '@/lib/docs/source';
|
||||
import { formatDate } from '@/lib/formatter';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
} from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import { CalendarIcon, FileTextIcon } from 'lucide-react';
|
||||
import type { Metadata } from 'next';
|
||||
|
@ -1,13 +1,13 @@
|
||||
import { getMDXComponents } from '@/components/custom/mdx-components';
|
||||
import * as Preview from '@/components/docs';
|
||||
import { getMDXComponents } from '@/components/docs/mdx-components';
|
||||
import {
|
||||
HoverCard,
|
||||
HoverCardContent,
|
||||
HoverCardTrigger,
|
||||
} from '@/components/ui/hover-card';
|
||||
import { LOCALES } from '@/i18n/routing';
|
||||
import { source } from '@/lib/docs/source';
|
||||
import { constructMetadata } from '@/lib/metadata';
|
||||
import { source } from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import Link from 'fumadocs-core/link';
|
||||
import {
|
||||
|
@ -3,7 +3,7 @@ import { Logo } from '@/components/layout/logo';
|
||||
import { ModeSwitcher } from '@/components/layout/mode-switcher';
|
||||
import { websiteConfig } from '@/config/website';
|
||||
import { docsI18nConfig } from '@/lib/docs/i18n';
|
||||
import { source } from '@/lib/docs/source';
|
||||
import { source } from '@/lib/source';
|
||||
import { getUrlWithLocale } from '@/lib/urls/urls';
|
||||
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
|
||||
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { docsI18nConfig } from '@/lib/docs/i18n';
|
||||
import { source } from '@/lib/docs/source';
|
||||
import { source } from '@/lib/source';
|
||||
import { createTokenizer } from '@orama/tokenizers/mandarin';
|
||||
import { createI18nSearchAPI } from 'fumadocs-core/search/server';
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { websiteConfig } from '@/config/website';
|
||||
import { getLocalePathname } from '@/i18n/navigation';
|
||||
import { routing } from '@/i18n/routing';
|
||||
import { blogSource, categorySource, source } from '@/lib/docs/source';
|
||||
import { blogSource, categorySource, source } from '@/lib/source';
|
||||
import type { MetadataRoute } from 'next';
|
||||
import type { Locale } from 'next-intl';
|
||||
import { getBaseUrl } from '../lib/urls/urls';
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { LocaleLink } from '@/i18n/navigation';
|
||||
import { PLACEHOLDER_IMAGE } from '@/lib/constants';
|
||||
import { type BlogType, authorSource, categorySource } from '@/lib/docs/source';
|
||||
import { formatDate } from '@/lib/formatter';
|
||||
import { type BlogType, authorSource, categorySource } from '@/lib/source';
|
||||
import Image from 'next/image';
|
||||
|
||||
interface BlogCardProps {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { BlogType } from '@/lib/docs/source';
|
||||
import type { BlogType } from '@/lib/source';
|
||||
import EmptyGrid from '../shared/empty-grid';
|
||||
import CustomPagination from '../shared/pagination';
|
||||
import BlogGrid from './blog-grid';
|
||||
|
@ -1,6 +1,6 @@
|
||||
import BlogCard, { BlogCardSkeleton } from '@/components/blog/blog-card';
|
||||
import { websiteConfig } from '@/config/website';
|
||||
import type { BlogType } from '@/lib/docs/source';
|
||||
import type { BlogType } from '@/lib/source';
|
||||
|
||||
interface BlogGridProps {
|
||||
locale: string;
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import type { ChangelogType } from '@/lib/docs/source';
|
||||
import { formatDate } from '@/lib/formatter';
|
||||
import type { ChangelogType } from '@/lib/source';
|
||||
import { CalendarIcon, TagIcon } from 'lucide-react';
|
||||
import { getMDXComponents } from '../custom/mdx-components';
|
||||
import { getMDXComponents } from '../docs/mdx-components';
|
||||
|
||||
interface ReleaseCardProps {
|
||||
releaseItem: ChangelogType;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import type { PagesType } from '@/lib/docs/source';
|
||||
import { formatDate } from '@/lib/formatter';
|
||||
import type { PagesType } from '@/lib/source';
|
||||
import { CalendarIcon } from 'lucide-react';
|
||||
import { getMDXComponents } from '../custom/mdx-components';
|
||||
import { getMDXComponents } from '../docs/mdx-components';
|
||||
import { Card, CardContent } from '../ui/card';
|
||||
|
||||
interface CustomPageProps {
|
||||
|
@ -2,15 +2,8 @@ import { type InferPageType, loader } from 'fumadocs-core/source';
|
||||
import { createMDXSource } from 'fumadocs-mdx';
|
||||
import * as LucideIcons from 'lucide-react';
|
||||
import { createElement } from 'react';
|
||||
import {
|
||||
author,
|
||||
blog,
|
||||
category,
|
||||
changelog,
|
||||
docs,
|
||||
pages,
|
||||
} from '../../../.source';
|
||||
import { docsI18nConfig } from './i18n';
|
||||
import { author, blog, category, changelog, docs, pages } from '../../.source';
|
||||
import { docsI18nConfig } from './docs/i18n';
|
||||
|
||||
/**
|
||||
* Turn a content source into a unified interface
|
@ -3,6 +3,7 @@ import createMiddleware from 'next-intl/middleware';
|
||||
import { type NextRequest, NextResponse } from 'next/server';
|
||||
import { LOCALES, routing } from './i18n/routing';
|
||||
import type { Session } from './lib/auth-types';
|
||||
import { getBaseUrl } from './lib/urls/urls';
|
||||
import {
|
||||
DEFAULT_LOGIN_REDIRECT,
|
||||
protectedRoutes,
|
||||
@ -30,7 +31,7 @@ export default async function middleware(req: NextRequest) {
|
||||
const { data: session } = await betterFetch<Session>(
|
||||
'/api/auth/get-session',
|
||||
{
|
||||
baseURL: req.nextUrl.origin,
|
||||
baseURL: getBaseUrl(),
|
||||
headers: {
|
||||
cookie: req.headers.get('cookie') || '', // Forward the cookies from the request
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user