lobehub/Dockerfile

344 lines
11 KiB
Text
Raw Permalink Normal View History

## Set global build ENV
ARG NODEJS_VERSION="24"
## Base image for all building stages
FROM node:${NODEJS_VERSION}-slim AS base
ARG USE_CN_MIRROR
ENV DEBIAN_FRONTEND="noninteractive"
RUN set -e && \
if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
sed -i "s/deb.debian.org/mirrors.ustc.edu.cn/g" "/etc/apt/sources.list.d/debian.sources"; \
fi && \
apt update && \
apt install ca-certificates proxychains-ng -qy && \
mkdir -p /distroless/bin /distroless/etc /distroless/etc/ssl/certs /distroless/lib && \
cp /usr/lib/$(arch)-linux-gnu/libproxychains.so.4 /distroless/lib/libproxychains.so.4 && \
cp /usr/lib/$(arch)-linux-gnu/libdl.so.2 /distroless/lib/libdl.so.2 && \
cp /usr/bin/proxychains4 /distroless/bin/proxychains && \
cp /etc/proxychains4.conf /distroless/etc/proxychains4.conf && \
cp /usr/lib/$(arch)-linux-gnu/libstdc++.so.6 /distroless/lib/libstdc++.so.6 && \
cp /usr/lib/$(arch)-linux-gnu/libgcc_s.so.1 /distroless/lib/libgcc_s.so.1 && \
cp /usr/lib/$(arch)-linux-gnu/librt.so.1 /distroless/lib/librt.so.1 && \
cp /usr/local/bin/node /distroless/bin/node && \
cp /etc/ssl/certs/ca-certificates.crt /distroless/etc/ssl/certs/ca-certificates.crt && \
rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*
## Builder image, install all the dependencies and build the app
FROM base AS builder
2023-10-10 19:26:19 +00:00
ARG USE_CN_MIRROR
ARG NEXT_PUBLIC_BASE_PATH
ARG NEXT_PUBLIC_SENTRY_DSN
ARG NEXT_PUBLIC_ANALYTICS_POSTHOG
ARG NEXT_PUBLIC_POSTHOG_HOST
ARG NEXT_PUBLIC_POSTHOG_KEY
ARG NEXT_PUBLIC_ANALYTICS_UMAMI
ARG NEXT_PUBLIC_UMAMI_SCRIPT_URL
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
ARG FEATURE_FLAGS
2024-05-06 02:07:57 +00:00
ENV NEXT_PUBLIC_BASE_PATH="${NEXT_PUBLIC_BASE_PATH}" \
FEATURE_FLAGS="${FEATURE_FLAGS}"
2025-10-30 13:02:42 +00:00
2026-01-23 15:57:08 +00:00
ENV APP_URL="http://app.com" \
2025-10-30 13:02:42 +00:00
DATABASE_DRIVER="node" \
DATABASE_URL="postgres://postgres:password@localhost:5432/postgres" \
KEY_VAULTS_SECRET="use-for-build" \
AUTH_SECRET="use-for-build"
2025-10-30 13:02:42 +00:00
2024-05-06 02:07:57 +00:00
# Sentry
ENV NEXT_PUBLIC_SENTRY_DSN="${NEXT_PUBLIC_SENTRY_DSN}" \
SENTRY_ORG="" \
SENTRY_PROJECT=""
2024-05-06 02:07:57 +00:00
# Posthog
ENV NEXT_PUBLIC_ANALYTICS_POSTHOG="${NEXT_PUBLIC_ANALYTICS_POSTHOG}" \
NEXT_PUBLIC_POSTHOG_HOST="${NEXT_PUBLIC_POSTHOG_HOST}" \
NEXT_PUBLIC_POSTHOG_KEY="${NEXT_PUBLIC_POSTHOG_KEY}"
2024-05-06 02:07:57 +00:00
# Umami
ENV NEXT_PUBLIC_ANALYTICS_UMAMI="${NEXT_PUBLIC_ANALYTICS_UMAMI}" \
NEXT_PUBLIC_UMAMI_SCRIPT_URL="${NEXT_PUBLIC_UMAMI_SCRIPT_URL}" \
NEXT_PUBLIC_UMAMI_WEBSITE_ID="${NEXT_PUBLIC_UMAMI_WEBSITE_ID}"
2024-05-06 02:07:57 +00:00
# Node
ENV NODE_OPTIONS="--max-old-space-size=8192"
2024-05-06 02:07:57 +00:00
2023-10-10 19:26:19 +00:00
WORKDIR /app
COPY package.json pnpm-workspace.yaml ./
COPY .npmrc ./
COPY packages ./packages
COPY patches ./patches
# bring in desktop workspace manifest so pnpm can resolve it
COPY apps/desktop/src/main/package.json ./apps/desktop/src/main/package.json
RUN set -e && \
if [ "${USE_CN_MIRROR:-false}" = "true" ]; then \
export SENTRYCLI_CDNURL="https://npmmirror.com/mirrors/sentry-cli"; \
npm config set registry "https://registry.npmmirror.com/"; \
echo 'canvas_binary_host_mirror=https://npmmirror.com/mirrors/canvas' >> .npmrc; \
fi && \
export COREPACK_NPM_REGISTRY=$(npm config get registry | sed 's/\/$//') && \
npm i -g corepack@latest && \
corepack enable && \
corepack use $(sed -n 's/.*"packageManager": "\(.*\)".*/\1/p' package.json) && \
pnpm i && \
mkdir -p /deps && \
cd /deps && \
pnpm init && \
pnpm add pg drizzle-orm
2023-10-10 19:26:19 +00:00
COPY . .
2023-10-10 19:26:19 +00:00
♻️ refactor: migrate frontend from Next.js App Router to Vite SPA (#12404) * init plan * 📝 docs: update SPA plan for dev mode Worker cross-origin handling - Clarified the handling of Worker cross-origin issues in dev mode, emphasizing the need for `workerPatch` to wrap cross-origin URLs as blob URLs. - Enhanced the explanation of the dev mode's resource URL rewriting process for better understanding. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: Phase 1 - 环境变量整治 - Fix Pyodide env var mismatch (NEXT_PUBLIC_PYPI_INDEX_URL → pythonEnv.NEXT_PUBLIC_PYODIDE_PIP_INDEX_URL) - Consolidate python.ts to use pythonEnv instead of direct process.env - Remove NEXT_PUBLIC_ prefix from server-side MARKET_BASE_URL (5 files) * 🏗️ chore: Phase 2 - Vite 工程搭建 - Add vite.config.ts with dual build (desktop/mobile via MOBILE env) - Add index.html SPA template with __SERVER_CONFIG__ placeholder - Add entry.desktop.tsx and entry.mobile.tsx SPA entry points - Add dev:spa, dev:spa:mobile, build:spa, build:spa:copy scripts - Install @vitejs/plugin-react and linkedom * ♻️ refactor: Phase 3 - 第一方包 Next.js 解耦 - Replace next/link with <a> in builtin-tool-web-browsing (4 files, external links) - Replace next/image with <img> in builtin-tool-agent-builder/InstallPlugin.tsx - Add Vite import.meta.env compat for isDesktop in const/version.ts, builtin-tool-gtd, builtin-tool-group-management * ♻️ refactor: Phase 4a - Auth 页面改用直接 next/navigation 和 next/link - 9 auth files: @/libs/next/navigation → next/navigation - 5 auth files: @/libs/next/Link → next/link - Auth pages remain in Next.js App Router, need direct Next.js imports * ♻️ refactor: Phase 4b - Next.js 抽象层替换为 react-router-dom/vanilla React - navigation.ts: useRouter/usePathname/useSearchParams/useParams → react-router-dom - navigation.ts: redirect/notFound → custom error throws - navigation.ts: useServerInsertedHTML → no-op for SPA - Link.tsx: next/link → react-router-dom Link adapter (href→to, external→<a>) - Image.tsx: next/image → <img> wrapper with fill/style support - dynamic.tsx: next/dynamic → React.lazy + Suspense wrapper * ✨ feat: Phase 5 - 新建 SPAGlobalProvider - Create SPAServerConfig type (analyticsConfig, clientEnv, theme, featureFlags, locale) - Add window.__SERVER_CONFIG__ and __MOBILE__ to global.d.ts - Create SPAGlobalProvider (client-only Provider tree mirroring GlobalProvider) - Includes AuthProvider for user session support - Update entry.desktop.tsx and entry.mobile.tsx to wrap with SPAGlobalProvider * ♻️ refactor: add SPA catch-all route handler with Vite dev proxy - Create (spa)/[[...path]]/route.ts for serving SPA HTML - Dev mode: proxy Vite dev server, rewrite asset URLs, inject Worker patch - Prod mode: read pre-built HTML templates - Build SPAServerConfig with analytics, theme, clientEnv, featureFlags - Update middleware to pass SPA routes through to catch-all * ♻️ refactor: skip auth checks for SPA routes in middleware SPA pages are all public (no sensitive data in HTML). Auth is handled client-side by SPAGlobalProvider's AuthProvider. Only Next.js auth routes and API endpoints go through session checks. * ♻️ refactor: replace Next.js-specific analytics with vanilla JS - Google.tsx: replace @next/third-parties/google with direct gtag script - ReactScan.tsx: replace react-scan/monitoring/next with generic script - Desktop.tsx: replace next/script with native script injection * ♻️ refactor: migrate @t3-oss/env-nextjs to @t3-oss/env-core Replace framework-specific env validation with framework-agnostic version. Add clientPrefix where client schemas exist. * ♻️ refactor: replace next-mdx-remote/rsc with react-markdown Use client-side react-markdown for MDX rendering instead of Next.js RSC-dependent next-mdx-remote. * 🔧 chore: update build scripts and Dockerfile for SPA integration - build:docker now includes SPA build + copy steps - dev defaults to Vite SPA, dev:next for Next.js backend - Dockerfile copies public/spa/ assets for production - Add public/spa/ to .gitignore (build artifact) * 🗑️ chore: remove old Next.js route segment files and serwist PWA - Delete [variants] page.tsx, error.tsx, not-found.tsx, loading.tsx - Delete root loading.tsx and empty [[...path]] directory - Delete unused loaders directory - Remove @serwist/next PWA wrapper from Next.js config * plan2 * ✨ feat: add locale detection script to index.html for SPA dev mode * ♻️ refactor: remove locale and theme from SPAServerConfig * ✨ feat: add [locale] segment with force-static and SEO meta generation * ♻️ refactor: remove theme/locale reads from SPAGlobalProvider * ✨ feat: set vite base to /spa/ for production builds * ✨ feat: auto-generate spaHtmlTemplates from vite build output * 🔧 chore: register dev:next task in turbo.json for parallel dev startup * ♻️ refactor: rename (spa) route group to spa segment, rewrite SPA routes via middleware * ✨ feat: add Vite-compatible i18n/locale modules with import.meta.glob and resolve aliases * 🔧 fix: use custom Vite plugin for module redirects instead of resolve.alias * very important * build * 🔧 chore: update build scripts and clean up Vite configuration by removing unused plugin and code Signed-off-by: Innei <tukon479@gmail.com> * 🗑️ refactor: remove all electron modifier scripts Modifiers are no longer needed with Vite SPA renderer build. * ✨ feat: add Vite renderer entry to electron-vite config Add renderer build configuration to electron-vite, replacing the old Next.js shadow workspace build flow. Delete buildNextApp.mts and moveNextExports.ts, update package.json scripts accordingly. * ✨ feat: add .desktop suffix files for eager i18n loading Create 4 .desktop files that use import.meta.glob({ eager: true }) for synchronous locale access in Electron desktop builds, replacing the async lazy-loading used in web SPA builds. * 🔧 refactor: adapt Electron main process for Vite renderer Replace nextExportDir with rendererDir, update protocol from app://next to app://renderer, simplify file resolution to SPA fallback pattern, update _next/ asset paths to /assets/. * 🔧 chore: update electron-builder files config for Vite renderer Replace dist/next references with dist/renderer, remove Next.js specific exclusion rules no longer applicable to Vite output. * 🗑️ chore: remove @ast-grep/napi dependency No longer needed after removing electron modifier scripts. * 🔧 refactor: unify isDesktop to __ELECTRON__ compile-time constant Remove NEXT_PUBLIC_IS_DESKTOP_APP and VITE_IS_DESKTOP_APP env vars. Unify isDesktop in @lobechat/const using __ELECTRON__ defined by Vite. Re-export from builtin-tool packages. Scripts use DESKTOP_BUILD. * update Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: use electron-vite ELECTRON_RENDERER_URL instead of hardcoded port 3015 Replace hardcoded http://localhost:3015 with process.env.ELECTRON_RENDERER_URL injected by electron-vite dev server. Clean up stale Next.js references. * 🐛 fix: use local renderer-entry shim to resolve Vite root path issue HTML entry ../../src/entry.desktop.tsx resolves to /src/entry.desktop.tsx in URL space, which Vite cannot find within apps/desktop/ root. Add a local shim that imports across root via module resolver instead. * 🔧 refactor: extract shared renderer Vite config into sharedRendererConfig Deduplicate plugins (nodeModuleStub, platformResolve, tsconfigPaths) and define (__MOBILE__, __ELECTRON__, process.env) between root vite.config.ts and electron.vite.config.ts renderer section. * 🔧 refactor: move all renderer plugins and optimizeDeps into shared config sharedRendererPlugins now includes react, codeInspectorPlugin alongside nodeModuleStub, platformResolve, tsconfigPaths. Add sharedOptimizeDeps for pre-bundling list. Both root and electron configs consume shared only. * 🐛 fix: set electron renderer root to monorepo root for correct glob resolution import.meta.glob with absolute paths (e.g. /node_modules/antd/...) resolved within apps/desktop/ instead of monorepo root. Change renderer root to ROOT_DIR, add electronDesktopHtmlPlugin middleware to rewrite / to /apps/desktop/index.html, and remove the now-unnecessary renderer-entry.ts shim. * desktop vite !! Signed-off-by: Innei <tukon479@gmail.com> * sync import !! Signed-off-by: Innei <tukon479@gmail.com> * clean ci!! Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: update SPA path structure and clean up dependencies - Changed the path in .gitignore and related files from [locale] to [variants] for SPA templates. - Updated index.html to set body height to 100%. - Cleaned up package.json by removing unused dependencies and reorganizing devDependencies. - Refactored RendererUrlManager to use a constant for SPA entry HTML path. - Removed obsolete route.ts file from the SPA structure. - Adjusted proxy configuration to reflect the new SPA path structure. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update build script to include mobile SPA build - Modified the build script in package.json to add the mobile SPA build step. - Ensured the build process accommodates both desktop and mobile SPA versions. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update build scripts and improve file encoding consistency - Modified the build script in package.json to ensure the SPA copy step runs after the build. - Updated file encoding in generateSpaTemplates.mts from 'utf-8' to 'utf8' for consistency. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 fix: correct Blob import syntax and update global server config type - Fixed the Blob import syntax in route.ts to ensure proper module loading. - Updated the global server configuration type in global.d.ts for improved type safety. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 test: update RendererUrlManager test to reflect new file path - Modified the mock implementation in RendererUrlManager.test.ts to check for the updated file path '/mock/export/out/apps/desktop/index.html'. - Adjusted the expected resolved path in the test to match the new structure. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: remove catch-all example file and update imports - Deleted the catch-all example file `catch-all.eg.ts` to streamline the codebase. - Updated import paths in `ClientResponsiveLayout.tsx` and `ClientResponsiveContent/index.tsx` to use the new dynamic import location. - Added type declarations for HTML templates in `spaHtmlTemplates.d.ts`. - Adjusted `tsconfig.json` to include the updated file structure. - Enhanced type definitions in `global.d.ts` and fixed locale loading in `locale.vite.ts`. Signed-off-by: Innei <tukon479@gmail.com> * e2e Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: remove unused build script for Vercel deployment - Deleted the `build:vercel` script from package.json to streamline the build process. - Ensured the remaining build scripts are organized and relevant. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 config: update Vite build input for mobile support - Changed the build input path in vite.config.ts to conditionally use 'index.mobile.html' for mobile builds, enhancing support for mobile SPA versions. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 feat: add compatibility checks for import maps and cascade layers - Implemented functions to check for browser support of import maps and CSS cascade layers. - Redirected users to a compatibility page if their browser does not support the required features. - Updated the build script in package.json to use the experimental analyze command for better performance. Signed-off-by: Innei <tukon479@gmail.com> * chore: rename Signed-off-by: Innei <tukon479@gmail.com> * 🔧 feat: refactor authentication layout and introduce global providers - Created a new `RootLayout` component to streamline the layout structure. - Removed the old layout file for variants and integrated necessary features into the new layout. - Added `AuthGlobalProvider` to manage authentication context and server configurations. - Introduced language and theme selection components for enhanced user experience. - Updated various components to utilize the new context and improve modularity. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 config: exclude build artifacts from serverless functions - Updated the `next.config.ts` to exclude SPA, desktop, and mobile build artifacts from serverless functions. - Added paths for `public/spa/**`, `dist/**`, `apps/desktop/build/**`, and `packages/database/migrations/**` to the exclusion list. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 config: refine exclusion of build artifacts from serverless functions - Updated `next.config.ts` to specify exclusion paths for desktop and mobile build artifacts. - Changed exclusions from `dist/**` and `apps/desktop/build/**` to `dist/desktop/**`, `dist/mobile/**`, and `apps/desktop/**` for better clarity and organization. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 fix: update BrowserRouter basename for local development - Modified the `ClientRouter` component to conditionally set the `basename` of `BrowserRouter` based on the `__DEBUG_PROXY__` variable, improving local development experience. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 feat: implement mobile SPA workflow and S3 asset management - Added a new workflow for building and uploading mobile SPA assets to S3, including environment variable configurations in `.env.example`. - Updated `package.json` to include a new script for the mobile SPA workflow. - Enhanced the Vite configuration to support dynamic CDN base paths. - Refactored the template generation script to handle mobile HTML templates more effectively. - Introduced new modules for uploading assets to S3 and generating mobile HTML templates. Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: extract origin from MOBILE_S3_PUBLIC_DOMAIN to prevent double key prefix * 🔧 fix: update mobile HTML template to use the latest asset versions - Modified the mobile HTML template to reference the updated JavaScript asset version for improved functionality. - Ensured consistency in the template structure while maintaining existing styles and scripts. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update dependencies and refine service worker integration - Removed outdated dependencies related to Serwist from package.json and tsconfig.json. - Added vite-plugin-pwa to enhance PWA capabilities in the Vite configuration. - Updated service worker registration logic in the PWA installation component. - Introduced a new local development proxy route for debugging purposes. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: refactor development scripts and remove Turbo configuration - Updated the `dev` script in `package.json` to use a new startup sequence script for improved development workflow. - Removed the outdated `turbo.json` configuration file as it is no longer needed. - Introduced `devStartupSequence.mts` to manage the startup of Next.js and Vite processes concurrently. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 feat: update entry points and introduce debug proxy for local development - Changed the main entry point in `index.html` from `entry.desktop.tsx` to `entry.web.tsx` for improved web compatibility. - Added an `initialize.ts` file to enable `immer`'s `enableMapSet` functionality. - Introduced a new `__DEBUG_PROXY__` variable in global types to support local development proxy features. - Implemented a debug proxy route to facilitate local development with dynamic HTML injection and script handling. - Removed outdated mobile routing components to streamline the codebase. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: replace BrowserRouter with RouterProvider for improved routing - Updated entry points for desktop, mobile, and web to utilize RouterProvider and createAppRouter for better routing management. - Removed the deprecated renderRoutes function in favor of a more streamlined router configuration. - Enhanced router setup to support error boundaries and dynamic routing. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: remove direct access handling for SPA routes in proxy configuration - Eliminated the handling of direct access to pre-rendered SPA pages in the proxy configuration. - Simplified the request processing logic by removing checks for SPA routes, streamlining the middleware response flow. Signed-off-by: Innei <tukon479@gmail.com> * update * 🔧 refactor: enhance Worker instantiation logic in mobile HTML template * 🐛 fix: remove duplicate waitForPageWorkspaceReady calls in page CRUD e2e steps * 🔧 refactor: simplify createTracePayload function by using btoa for base64 encoding * 🔧 refactor: specify locales in import.meta.glob for dayjs and antd * 🔧 refactor: replace Node.js Buffer with web-compatible btoa for base64 encoding in file upload * 🐛 fix: disable consistent-type-imports rule for mdx files to prevent eslint crash * 🔧 refactor: add height style to root div for consistent layout * 🔧 refactor: replace btoa with Buffer for base64 encoding in trace and file upload handling * 🔧 refactor: extract nextjsOnlyRoutes to a separate file for better organization * 🔧 refactor: enable Immer MapSet plugin in tests for better state management Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: integrate sharedRollupOutput configuration and increase cache size for better performance Signed-off-by: Innei <tukon479@gmail.com> * 🗑️ chore: remove obsolete desktop.routes.test.ts file as it is no longer needed Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: use cross-env for env vars in npm scripts (Windows CI) Co-authored-by: Cursor <cursoragent@cursor.com> * 🔧 chore: update Dockerfile for web-only build and adjust npm scripts to use pnpm Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: enhance Dockerfile prebuild process with environment checks and add new dependencies - Updated Dockerfile to include environment checks before removing desktop-only code. - Added new dependencies in package.json: @aws-sdk/client-bedrock-runtime, @opentelemetry/auto-instrumentations-node, @opentelemetry/resources, @opentelemetry/sdk-metrics, and ajv. - Configured Rollup to exclude @aws-sdk/client-bedrock-runtime from the SPA bundle. - Introduced dockerPrebuild.mts script for environment variable validation and information logging. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: enhance Vite and Electron configurations with environment loading and trace encoding improvements - Updated Vite and Electron configurations to load environment variables using loadEnv. - Modified trace encoding in utils to use TextEncoder for better compatibility. - Adjusted sharedRendererConfig to expose only necessary public environment variables. Signed-off-by: Innei <tukon479@gmail.com> * 🗑️ chore: remove plans directory (migrated to discussion) * ♻️ refactor: inject NEXT_PUBLIC_* env per key in Vite define Co-authored-by: Cursor <cursoragent@cursor.com> * ✨ feat: add loading screen with animation to enhance user experience - Introduced a loading screen with a brand logo and animations for better visual feedback during loading times. - Implemented CSS styles for the loading screen and animations in index.html. - Removed the loading screen from the DOM once the layout is ready using useLayoutEffect in SPAGlobalProvider. Signed-off-by: Innei <tukon479@gmail.com> * 🗑️ chore: remove unnecessary external dependency from Vite configuration - Eliminated the external dependency '@aws-sdk/client-bedrock-runtime' from the Vite configuration to streamline the build process for the SPA bundle. Signed-off-by: Innei <tukon479@gmail.com> * ✨ feat: add web app manifest link in index.html and enable PWA support in Vite configuration - Added a link to the web app manifest in index.html to enhance PWA capabilities. - Enabled manifest support in Vite configuration for improved service worker functionality. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update link rel attributes for improved SEO and consistency - Modified link rel attributes in multiple components to remove 'noreferrer' and standardize to 'nofollow'. - Adjusted imports in PageContent components for better organization. Signed-off-by: Innei <tukon479@gmail.com> * update provider * ✨ feat: enhance loading experience and update package dependencies - Added a loading screen with animations and a brand logo in index.html for improved user feedback during loading times. - Introduced CSS styles for the loading screen and animations. - Updated package.json files across multiple packages to include "@lobechat/const" as a dependency. Signed-off-by: Innei <tukon479@gmail.com> * fix: update proxy Signed-off-by: Innei <tukon479@gmail.com> * 🗑️ chore: remove GlobalLayout and Locale components - Deleted GlobalLayout and Locale components from the GlobalProvider directory to streamline the codebase. - This removal is part of a refactor to simplify the layout structure and improve maintainability. Signed-off-by: Innei <tukon479@gmail.com> * chore: clean up console logs and improve component structure - Removed unnecessary console log statements from AgentForkTag components in both agent and community directories to enhance code cleanliness. - Refactored UserAgentList component for better readability by restructuring the useUserDetailContext hook and adjusting the layout of Flexbox components. Signed-off-by: Innei <tukon479@gmail.com> * chore: remove console log from MemoryAnalysis component * chore: update mobile HTML template with new asset links - Replaced the previous asset links in the mobile HTML template with updated versions to ensure the latest resources are utilized. - Adjusted the link rel attributes for module preloading to enhance performance and loading efficiency. Signed-off-by: Innei <tukon479@gmail.com> * fix: correct variable assignment in createClientTaskThread integration test - Updated the assignment of the second parent message in the createClientTaskThread integration test to improve clarity and ensure proper data handling. - Changed the variable name from 'secondParentMsg' to 'inserted' for better context before extracting the first message from the inserted results. Signed-off-by: Innei <tukon479@gmail.com> * refactor: simplify authentication check in define-config - Removed the dependency on the isDesktop variable in the authentication check to streamline the logic. - Enhanced the clarity of the redirection process for protected routes by focusing solely on the isLoggedIn status. Signed-off-by: Innei <tukon479@gmail.com> * ✨ feat(dev): enhance local development setup with debug proxy instructions - Added detailed instructions for starting the development environment in CLAUDE.md, including commands for SPA and full-stack modes. - Updated README.md and README.zh-CN.md to reflect new commands and the debug proxy URL for local development. - Introduced a Vite plugin to print the debug proxy URL upon server start, facilitating easier local development against the production backend. - Corrected the debug proxy route in entry.web.tsx and define-config.ts for consistency. This improves the developer experience by providing clear guidance and tools for local development. Signed-off-by: Innei <tukon479@gmail.com> * optimize perf * optimize perf * optimize perf * remove speedy plugin * add dayjs vendor * Revert "remove speedy plugin" This reverts commit bf986afeb114939c2bddfa41ff24827ea8559183. --------- Signed-off-by: Innei <tukon479@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-27 16:01:01 +00:00
# Prebuild: env checks (checkDeprecatedAuth, checkRequiredEnvVars, printEnvInfo) then remove desktop-only code
RUN pnpm exec tsx scripts/dockerPrebuild.mts
RUN rm -rf src/app/desktop "src/app/(backend)/trpc/desktop"
# run build standalone for docker version
RUN npm run build:docker
2023-10-10 19:26:19 +00:00
## Application image, copy all the files for production
FROM busybox:latest AS app
COPY --from=base /distroless/ /
2023-10-10 19:26:19 +00:00
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder /app/.next/standalone /app/
COPY --from=builder /app/.next/static /app/.next/static
♻️ refactor: migrate frontend from Next.js App Router to Vite SPA (#12404) * init plan * 📝 docs: update SPA plan for dev mode Worker cross-origin handling - Clarified the handling of Worker cross-origin issues in dev mode, emphasizing the need for `workerPatch` to wrap cross-origin URLs as blob URLs. - Enhanced the explanation of the dev mode's resource URL rewriting process for better understanding. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: Phase 1 - 环境变量整治 - Fix Pyodide env var mismatch (NEXT_PUBLIC_PYPI_INDEX_URL → pythonEnv.NEXT_PUBLIC_PYODIDE_PIP_INDEX_URL) - Consolidate python.ts to use pythonEnv instead of direct process.env - Remove NEXT_PUBLIC_ prefix from server-side MARKET_BASE_URL (5 files) * 🏗️ chore: Phase 2 - Vite 工程搭建 - Add vite.config.ts with dual build (desktop/mobile via MOBILE env) - Add index.html SPA template with __SERVER_CONFIG__ placeholder - Add entry.desktop.tsx and entry.mobile.tsx SPA entry points - Add dev:spa, dev:spa:mobile, build:spa, build:spa:copy scripts - Install @vitejs/plugin-react and linkedom * ♻️ refactor: Phase 3 - 第一方包 Next.js 解耦 - Replace next/link with <a> in builtin-tool-web-browsing (4 files, external links) - Replace next/image with <img> in builtin-tool-agent-builder/InstallPlugin.tsx - Add Vite import.meta.env compat for isDesktop in const/version.ts, builtin-tool-gtd, builtin-tool-group-management * ♻️ refactor: Phase 4a - Auth 页面改用直接 next/navigation 和 next/link - 9 auth files: @/libs/next/navigation → next/navigation - 5 auth files: @/libs/next/Link → next/link - Auth pages remain in Next.js App Router, need direct Next.js imports * ♻️ refactor: Phase 4b - Next.js 抽象层替换为 react-router-dom/vanilla React - navigation.ts: useRouter/usePathname/useSearchParams/useParams → react-router-dom - navigation.ts: redirect/notFound → custom error throws - navigation.ts: useServerInsertedHTML → no-op for SPA - Link.tsx: next/link → react-router-dom Link adapter (href→to, external→<a>) - Image.tsx: next/image → <img> wrapper with fill/style support - dynamic.tsx: next/dynamic → React.lazy + Suspense wrapper * ✨ feat: Phase 5 - 新建 SPAGlobalProvider - Create SPAServerConfig type (analyticsConfig, clientEnv, theme, featureFlags, locale) - Add window.__SERVER_CONFIG__ and __MOBILE__ to global.d.ts - Create SPAGlobalProvider (client-only Provider tree mirroring GlobalProvider) - Includes AuthProvider for user session support - Update entry.desktop.tsx and entry.mobile.tsx to wrap with SPAGlobalProvider * ♻️ refactor: add SPA catch-all route handler with Vite dev proxy - Create (spa)/[[...path]]/route.ts for serving SPA HTML - Dev mode: proxy Vite dev server, rewrite asset URLs, inject Worker patch - Prod mode: read pre-built HTML templates - Build SPAServerConfig with analytics, theme, clientEnv, featureFlags - Update middleware to pass SPA routes through to catch-all * ♻️ refactor: skip auth checks for SPA routes in middleware SPA pages are all public (no sensitive data in HTML). Auth is handled client-side by SPAGlobalProvider's AuthProvider. Only Next.js auth routes and API endpoints go through session checks. * ♻️ refactor: replace Next.js-specific analytics with vanilla JS - Google.tsx: replace @next/third-parties/google with direct gtag script - ReactScan.tsx: replace react-scan/monitoring/next with generic script - Desktop.tsx: replace next/script with native script injection * ♻️ refactor: migrate @t3-oss/env-nextjs to @t3-oss/env-core Replace framework-specific env validation with framework-agnostic version. Add clientPrefix where client schemas exist. * ♻️ refactor: replace next-mdx-remote/rsc with react-markdown Use client-side react-markdown for MDX rendering instead of Next.js RSC-dependent next-mdx-remote. * 🔧 chore: update build scripts and Dockerfile for SPA integration - build:docker now includes SPA build + copy steps - dev defaults to Vite SPA, dev:next for Next.js backend - Dockerfile copies public/spa/ assets for production - Add public/spa/ to .gitignore (build artifact) * 🗑️ chore: remove old Next.js route segment files and serwist PWA - Delete [variants] page.tsx, error.tsx, not-found.tsx, loading.tsx - Delete root loading.tsx and empty [[...path]] directory - Delete unused loaders directory - Remove @serwist/next PWA wrapper from Next.js config * plan2 * ✨ feat: add locale detection script to index.html for SPA dev mode * ♻️ refactor: remove locale and theme from SPAServerConfig * ✨ feat: add [locale] segment with force-static and SEO meta generation * ♻️ refactor: remove theme/locale reads from SPAGlobalProvider * ✨ feat: set vite base to /spa/ for production builds * ✨ feat: auto-generate spaHtmlTemplates from vite build output * 🔧 chore: register dev:next task in turbo.json for parallel dev startup * ♻️ refactor: rename (spa) route group to spa segment, rewrite SPA routes via middleware * ✨ feat: add Vite-compatible i18n/locale modules with import.meta.glob and resolve aliases * 🔧 fix: use custom Vite plugin for module redirects instead of resolve.alias * very important * build * 🔧 chore: update build scripts and clean up Vite configuration by removing unused plugin and code Signed-off-by: Innei <tukon479@gmail.com> * 🗑️ refactor: remove all electron modifier scripts Modifiers are no longer needed with Vite SPA renderer build. * ✨ feat: add Vite renderer entry to electron-vite config Add renderer build configuration to electron-vite, replacing the old Next.js shadow workspace build flow. Delete buildNextApp.mts and moveNextExports.ts, update package.json scripts accordingly. * ✨ feat: add .desktop suffix files for eager i18n loading Create 4 .desktop files that use import.meta.glob({ eager: true }) for synchronous locale access in Electron desktop builds, replacing the async lazy-loading used in web SPA builds. * 🔧 refactor: adapt Electron main process for Vite renderer Replace nextExportDir with rendererDir, update protocol from app://next to app://renderer, simplify file resolution to SPA fallback pattern, update _next/ asset paths to /assets/. * 🔧 chore: update electron-builder files config for Vite renderer Replace dist/next references with dist/renderer, remove Next.js specific exclusion rules no longer applicable to Vite output. * 🗑️ chore: remove @ast-grep/napi dependency No longer needed after removing electron modifier scripts. * 🔧 refactor: unify isDesktop to __ELECTRON__ compile-time constant Remove NEXT_PUBLIC_IS_DESKTOP_APP and VITE_IS_DESKTOP_APP env vars. Unify isDesktop in @lobechat/const using __ELECTRON__ defined by Vite. Re-export from builtin-tool packages. Scripts use DESKTOP_BUILD. * update Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: use electron-vite ELECTRON_RENDERER_URL instead of hardcoded port 3015 Replace hardcoded http://localhost:3015 with process.env.ELECTRON_RENDERER_URL injected by electron-vite dev server. Clean up stale Next.js references. * 🐛 fix: use local renderer-entry shim to resolve Vite root path issue HTML entry ../../src/entry.desktop.tsx resolves to /src/entry.desktop.tsx in URL space, which Vite cannot find within apps/desktop/ root. Add a local shim that imports across root via module resolver instead. * 🔧 refactor: extract shared renderer Vite config into sharedRendererConfig Deduplicate plugins (nodeModuleStub, platformResolve, tsconfigPaths) and define (__MOBILE__, __ELECTRON__, process.env) between root vite.config.ts and electron.vite.config.ts renderer section. * 🔧 refactor: move all renderer plugins and optimizeDeps into shared config sharedRendererPlugins now includes react, codeInspectorPlugin alongside nodeModuleStub, platformResolve, tsconfigPaths. Add sharedOptimizeDeps for pre-bundling list. Both root and electron configs consume shared only. * 🐛 fix: set electron renderer root to monorepo root for correct glob resolution import.meta.glob with absolute paths (e.g. /node_modules/antd/...) resolved within apps/desktop/ instead of monorepo root. Change renderer root to ROOT_DIR, add electronDesktopHtmlPlugin middleware to rewrite / to /apps/desktop/index.html, and remove the now-unnecessary renderer-entry.ts shim. * desktop vite !! Signed-off-by: Innei <tukon479@gmail.com> * sync import !! Signed-off-by: Innei <tukon479@gmail.com> * clean ci!! Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: update SPA path structure and clean up dependencies - Changed the path in .gitignore and related files from [locale] to [variants] for SPA templates. - Updated index.html to set body height to 100%. - Cleaned up package.json by removing unused dependencies and reorganizing devDependencies. - Refactored RendererUrlManager to use a constant for SPA entry HTML path. - Removed obsolete route.ts file from the SPA structure. - Adjusted proxy configuration to reflect the new SPA path structure. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update build script to include mobile SPA build - Modified the build script in package.json to add the mobile SPA build step. - Ensured the build process accommodates both desktop and mobile SPA versions. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update build scripts and improve file encoding consistency - Modified the build script in package.json to ensure the SPA copy step runs after the build. - Updated file encoding in generateSpaTemplates.mts from 'utf-8' to 'utf8' for consistency. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 fix: correct Blob import syntax and update global server config type - Fixed the Blob import syntax in route.ts to ensure proper module loading. - Updated the global server configuration type in global.d.ts for improved type safety. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 test: update RendererUrlManager test to reflect new file path - Modified the mock implementation in RendererUrlManager.test.ts to check for the updated file path '/mock/export/out/apps/desktop/index.html'. - Adjusted the expected resolved path in the test to match the new structure. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: remove catch-all example file and update imports - Deleted the catch-all example file `catch-all.eg.ts` to streamline the codebase. - Updated import paths in `ClientResponsiveLayout.tsx` and `ClientResponsiveContent/index.tsx` to use the new dynamic import location. - Added type declarations for HTML templates in `spaHtmlTemplates.d.ts`. - Adjusted `tsconfig.json` to include the updated file structure. - Enhanced type definitions in `global.d.ts` and fixed locale loading in `locale.vite.ts`. Signed-off-by: Innei <tukon479@gmail.com> * e2e Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: remove unused build script for Vercel deployment - Deleted the `build:vercel` script from package.json to streamline the build process. - Ensured the remaining build scripts are organized and relevant. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 config: update Vite build input for mobile support - Changed the build input path in vite.config.ts to conditionally use 'index.mobile.html' for mobile builds, enhancing support for mobile SPA versions. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 feat: add compatibility checks for import maps and cascade layers - Implemented functions to check for browser support of import maps and CSS cascade layers. - Redirected users to a compatibility page if their browser does not support the required features. - Updated the build script in package.json to use the experimental analyze command for better performance. Signed-off-by: Innei <tukon479@gmail.com> * chore: rename Signed-off-by: Innei <tukon479@gmail.com> * 🔧 feat: refactor authentication layout and introduce global providers - Created a new `RootLayout` component to streamline the layout structure. - Removed the old layout file for variants and integrated necessary features into the new layout. - Added `AuthGlobalProvider` to manage authentication context and server configurations. - Introduced language and theme selection components for enhanced user experience. - Updated various components to utilize the new context and improve modularity. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 config: exclude build artifacts from serverless functions - Updated the `next.config.ts` to exclude SPA, desktop, and mobile build artifacts from serverless functions. - Added paths for `public/spa/**`, `dist/**`, `apps/desktop/build/**`, and `packages/database/migrations/**` to the exclusion list. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 config: refine exclusion of build artifacts from serverless functions - Updated `next.config.ts` to specify exclusion paths for desktop and mobile build artifacts. - Changed exclusions from `dist/**` and `apps/desktop/build/**` to `dist/desktop/**`, `dist/mobile/**`, and `apps/desktop/**` for better clarity and organization. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 fix: update BrowserRouter basename for local development - Modified the `ClientRouter` component to conditionally set the `basename` of `BrowserRouter` based on the `__DEBUG_PROXY__` variable, improving local development experience. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 feat: implement mobile SPA workflow and S3 asset management - Added a new workflow for building and uploading mobile SPA assets to S3, including environment variable configurations in `.env.example`. - Updated `package.json` to include a new script for the mobile SPA workflow. - Enhanced the Vite configuration to support dynamic CDN base paths. - Refactored the template generation script to handle mobile HTML templates more effectively. - Introduced new modules for uploading assets to S3 and generating mobile HTML templates. Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: extract origin from MOBILE_S3_PUBLIC_DOMAIN to prevent double key prefix * 🔧 fix: update mobile HTML template to use the latest asset versions - Modified the mobile HTML template to reference the updated JavaScript asset version for improved functionality. - Ensured consistency in the template structure while maintaining existing styles and scripts. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update dependencies and refine service worker integration - Removed outdated dependencies related to Serwist from package.json and tsconfig.json. - Added vite-plugin-pwa to enhance PWA capabilities in the Vite configuration. - Updated service worker registration logic in the PWA installation component. - Introduced a new local development proxy route for debugging purposes. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: refactor development scripts and remove Turbo configuration - Updated the `dev` script in `package.json` to use a new startup sequence script for improved development workflow. - Removed the outdated `turbo.json` configuration file as it is no longer needed. - Introduced `devStartupSequence.mts` to manage the startup of Next.js and Vite processes concurrently. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 feat: update entry points and introduce debug proxy for local development - Changed the main entry point in `index.html` from `entry.desktop.tsx` to `entry.web.tsx` for improved web compatibility. - Added an `initialize.ts` file to enable `immer`'s `enableMapSet` functionality. - Introduced a new `__DEBUG_PROXY__` variable in global types to support local development proxy features. - Implemented a debug proxy route to facilitate local development with dynamic HTML injection and script handling. - Removed outdated mobile routing components to streamline the codebase. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: replace BrowserRouter with RouterProvider for improved routing - Updated entry points for desktop, mobile, and web to utilize RouterProvider and createAppRouter for better routing management. - Removed the deprecated renderRoutes function in favor of a more streamlined router configuration. - Enhanced router setup to support error boundaries and dynamic routing. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: remove direct access handling for SPA routes in proxy configuration - Eliminated the handling of direct access to pre-rendered SPA pages in the proxy configuration. - Simplified the request processing logic by removing checks for SPA routes, streamlining the middleware response flow. Signed-off-by: Innei <tukon479@gmail.com> * update * 🔧 refactor: enhance Worker instantiation logic in mobile HTML template * 🐛 fix: remove duplicate waitForPageWorkspaceReady calls in page CRUD e2e steps * 🔧 refactor: simplify createTracePayload function by using btoa for base64 encoding * 🔧 refactor: specify locales in import.meta.glob for dayjs and antd * 🔧 refactor: replace Node.js Buffer with web-compatible btoa for base64 encoding in file upload * 🐛 fix: disable consistent-type-imports rule for mdx files to prevent eslint crash * 🔧 refactor: add height style to root div for consistent layout * 🔧 refactor: replace btoa with Buffer for base64 encoding in trace and file upload handling * 🔧 refactor: extract nextjsOnlyRoutes to a separate file for better organization * 🔧 refactor: enable Immer MapSet plugin in tests for better state management Signed-off-by: Innei <tukon479@gmail.com> * 🔧 refactor: integrate sharedRollupOutput configuration and increase cache size for better performance Signed-off-by: Innei <tukon479@gmail.com> * 🗑️ chore: remove obsolete desktop.routes.test.ts file as it is no longer needed Signed-off-by: Innei <tukon479@gmail.com> * 🐛 fix: use cross-env for env vars in npm scripts (Windows CI) Co-authored-by: Cursor <cursoragent@cursor.com> * 🔧 chore: update Dockerfile for web-only build and adjust npm scripts to use pnpm Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: enhance Dockerfile prebuild process with environment checks and add new dependencies - Updated Dockerfile to include environment checks before removing desktop-only code. - Added new dependencies in package.json: @aws-sdk/client-bedrock-runtime, @opentelemetry/auto-instrumentations-node, @opentelemetry/resources, @opentelemetry/sdk-metrics, and ajv. - Configured Rollup to exclude @aws-sdk/client-bedrock-runtime from the SPA bundle. - Introduced dockerPrebuild.mts script for environment variable validation and information logging. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: enhance Vite and Electron configurations with environment loading and trace encoding improvements - Updated Vite and Electron configurations to load environment variables using loadEnv. - Modified trace encoding in utils to use TextEncoder for better compatibility. - Adjusted sharedRendererConfig to expose only necessary public environment variables. Signed-off-by: Innei <tukon479@gmail.com> * 🗑️ chore: remove plans directory (migrated to discussion) * ♻️ refactor: inject NEXT_PUBLIC_* env per key in Vite define Co-authored-by: Cursor <cursoragent@cursor.com> * ✨ feat: add loading screen with animation to enhance user experience - Introduced a loading screen with a brand logo and animations for better visual feedback during loading times. - Implemented CSS styles for the loading screen and animations in index.html. - Removed the loading screen from the DOM once the layout is ready using useLayoutEffect in SPAGlobalProvider. Signed-off-by: Innei <tukon479@gmail.com> * 🗑️ chore: remove unnecessary external dependency from Vite configuration - Eliminated the external dependency '@aws-sdk/client-bedrock-runtime' from the Vite configuration to streamline the build process for the SPA bundle. Signed-off-by: Innei <tukon479@gmail.com> * ✨ feat: add web app manifest link in index.html and enable PWA support in Vite configuration - Added a link to the web app manifest in index.html to enhance PWA capabilities. - Enabled manifest support in Vite configuration for improved service worker functionality. Signed-off-by: Innei <tukon479@gmail.com> * 🔧 chore: update link rel attributes for improved SEO and consistency - Modified link rel attributes in multiple components to remove 'noreferrer' and standardize to 'nofollow'. - Adjusted imports in PageContent components for better organization. Signed-off-by: Innei <tukon479@gmail.com> * update provider * ✨ feat: enhance loading experience and update package dependencies - Added a loading screen with animations and a brand logo in index.html for improved user feedback during loading times. - Introduced CSS styles for the loading screen and animations. - Updated package.json files across multiple packages to include "@lobechat/const" as a dependency. Signed-off-by: Innei <tukon479@gmail.com> * fix: update proxy Signed-off-by: Innei <tukon479@gmail.com> * 🗑️ chore: remove GlobalLayout and Locale components - Deleted GlobalLayout and Locale components from the GlobalProvider directory to streamline the codebase. - This removal is part of a refactor to simplify the layout structure and improve maintainability. Signed-off-by: Innei <tukon479@gmail.com> * chore: clean up console logs and improve component structure - Removed unnecessary console log statements from AgentForkTag components in both agent and community directories to enhance code cleanliness. - Refactored UserAgentList component for better readability by restructuring the useUserDetailContext hook and adjusting the layout of Flexbox components. Signed-off-by: Innei <tukon479@gmail.com> * chore: remove console log from MemoryAnalysis component * chore: update mobile HTML template with new asset links - Replaced the previous asset links in the mobile HTML template with updated versions to ensure the latest resources are utilized. - Adjusted the link rel attributes for module preloading to enhance performance and loading efficiency. Signed-off-by: Innei <tukon479@gmail.com> * fix: correct variable assignment in createClientTaskThread integration test - Updated the assignment of the second parent message in the createClientTaskThread integration test to improve clarity and ensure proper data handling. - Changed the variable name from 'secondParentMsg' to 'inserted' for better context before extracting the first message from the inserted results. Signed-off-by: Innei <tukon479@gmail.com> * refactor: simplify authentication check in define-config - Removed the dependency on the isDesktop variable in the authentication check to streamline the logic. - Enhanced the clarity of the redirection process for protected routes by focusing solely on the isLoggedIn status. Signed-off-by: Innei <tukon479@gmail.com> * ✨ feat(dev): enhance local development setup with debug proxy instructions - Added detailed instructions for starting the development environment in CLAUDE.md, including commands for SPA and full-stack modes. - Updated README.md and README.zh-CN.md to reflect new commands and the debug proxy URL for local development. - Introduced a Vite plugin to print the debug proxy URL upon server start, facilitating easier local development against the production backend. - Corrected the debug proxy route in entry.web.tsx and define-config.ts for consistency. This improves the developer experience by providing clear guidance and tools for local development. Signed-off-by: Innei <tukon479@gmail.com> * optimize perf * optimize perf * optimize perf * remove speedy plugin * add dayjs vendor * Revert "remove speedy plugin" This reverts commit bf986afeb114939c2bddfa41ff24827ea8559183. --------- Signed-off-by: Innei <tukon479@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-27 16:01:01 +00:00
# Copy SPA assets (Vite build output)
COPY --from=builder /app/public/_spa /app/public/_spa
2025-10-30 13:02:42 +00:00
# Copy database migrations
COPY --from=builder /app/packages/database/migrations /app/migrations
COPY --from=builder /app/scripts/migrateServerDB/docker.cjs /app/docker.cjs
COPY --from=builder /app/scripts/migrateServerDB/errorHint.js /app/errorHint.js
# copy dependencies
COPY --from=builder /deps/node_modules/.pnpm /app/node_modules/.pnpm
COPY --from=builder /deps/node_modules/pg /app/node_modules/pg
COPY --from=builder /deps/node_modules/drizzle-orm /app/node_modules/drizzle-orm
# Copy server launcher and shared scripts
COPY --from=builder /app/scripts/serverLauncher/startServer.js /app/startServer.js
COPY --from=builder /app/scripts/_shared /app/scripts/_shared
RUN set -e && \
addgroup -S -g 1001 nodejs && \
adduser -D -G nodejs -H -S -h /app -u 1001 nextjs && \
chown -R nextjs:nodejs /app /etc/proxychains4.conf
## Production image, copy all the files and run next
FROM scratch
2023-10-10 19:26:19 +00:00
# Copy all the files from app, set the correct permission for prerender cache
COPY --from=app / /
ENV NODE_ENV="production" \
NODE_OPTIONS="--dns-result-order=ipv4first --use-openssl-ca" \
NODE_EXTRA_CA_CERTS="" \
NODE_TLS_REJECT_UNAUTHORIZED="" \
SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt"
2023-10-10 19:26:19 +00:00
# Make the middleware rewrite through local as default
# refs: https://github.com/lobehub/lobehub/issues/5876
ENV MIDDLEWARE_REWRITE_THROUGH_LOCAL="1"
2023-10-10 19:26:19 +00:00
# set hostname to localhost
ENV HOSTNAME="0.0.0.0" \
PORT="3210"
2023-10-10 19:26:19 +00:00
# General Variables
ENV APP_URL="" \
API_KEY_SELECT_MODE="" \
DEFAULT_AGENT_CONFIG="" \
SYSTEM_AGENT="" \
FEATURE_FLAGS="" \
PROXY_URL=""
2025-10-30 13:02:42 +00:00
# Database
ENV KEY_VAULTS_SECRET="" \
DATABASE_DRIVER="node" \
DATABASE_URL=""
2025-11-27 12:10:40 +00:00
# Better Auth
ENV AUTH_SECRET="" \
2026-01-23 15:57:08 +00:00
AUTH_SSO_PROVIDERS="" \
AUTH_ALLOWED_EMAILS="" \
AUTH_TRUSTED_ORIGINS="" \
AUTH_DISABLE_EMAIL_PASSWORD="" \
AUTH_EMAIL_VERIFICATION="" \
AUTH_ENABLE_MAGIC_LINK="" \
2026-01-23 15:57:08 +00:00
# Google
AUTH_GOOGLE_ID="" \
AUTH_GOOGLE_SECRET="" \
# GitHub
AUTH_GITHUB_ID="" \
AUTH_GITHUB_SECRET="" \
# Microsoft
AUTH_MICROSOFT_ID="" \
AUTH_MICROSOFT_SECRET="" \
AUTH_MICROSOFT_AUTHORITY_URL="" \
AUTH_MICROSOFT_TENANT_ID=""
2026-01-23 15:57:08 +00:00
# Redis
ENV REDIS_URL="" \
REDIS_PREFIX="" \
REDIS_TLS=""
# Email
ENV EMAIL_SERVICE_PROVIDER="" \
SMTP_HOST="" \
SMTP_PORT="" \
SMTP_SECURE="" \
SMTP_USER="" \
SMTP_PASS="" \
SMTP_FROM="" \
RESEND_API_KEY="" \
RESEND_FROM=""
2025-10-30 13:02:42 +00:00
# S3
ENV NEXT_PUBLIC_S3_DOMAIN="" \
S3_PUBLIC_DOMAIN="" \
S3_ACCESS_KEY_ID="" \
S3_BUCKET="" \
S3_ENDPOINT="" \
S3_SECRET_ACCESS_KEY="" \
S3_ENABLE_PATH_STYLE="" \
S3_SET_ACL=""
# Model Variables
ENV \
# AI21
AI21_API_KEY="" AI21_MODEL_LIST="" \
# Ai360
AI360_API_KEY="" AI360_MODEL_LIST="" \
# AiHubMix
AIHUBMIX_API_KEY="" AIHUBMIX_MODEL_LIST="" \
# Anthropic
ANTHROPIC_API_KEY="" ANTHROPIC_MODEL_LIST="" ANTHROPIC_PROXY_URL="" \
# Amazon Bedrock
ENABLED_AWS_BEDROCK="" AWS_ACCESS_KEY_ID="" AWS_SECRET_ACCESS_KEY="" AWS_REGION="" AWS_BEDROCK_MODEL_LIST="" \
# Azure OpenAI
AZURE_API_KEY="" AZURE_API_VERSION="" AZURE_ENDPOINT="" AZURE_MODEL_LIST="" \
# Baichuan
BAICHUAN_API_KEY="" BAICHUAN_MODEL_LIST="" \
# Cloudflare
CLOUDFLARE_API_KEY="" CLOUDFLARE_BASE_URL_OR_ACCOUNT_ID="" CLOUDFLARE_MODEL_LIST="" \
# Cohere
COHERE_API_KEY="" COHERE_MODEL_LIST="" COHERE_PROXY_URL="" \
# ComfyUI
ENABLED_COMFYUI="" COMFYUI_BASE_URL="" COMFYUI_AUTH_TYPE="" \
COMFYUI_API_KEY="" COMFYUI_USERNAME="" COMFYUI_PASSWORD="" COMFYUI_CUSTOM_HEADERS="" \
# DeepSeek
DEEPSEEK_API_KEY="" DEEPSEEK_MODEL_LIST="" \
# Fireworks AI
FIREWORKSAI_API_KEY="" FIREWORKSAI_MODEL_LIST="" \
# Gitee AI
GITEE_AI_API_KEY="" GITEE_AI_MODEL_LIST="" \
# GitHub
GITHUB_TOKEN="" GITHUB_MODEL_LIST="" \
# Google
GOOGLE_API_KEY="" GOOGLE_MODEL_LIST="" GOOGLE_PROXY_URL="" \
# Vertex AI
VERTEXAI_CREDENTIALS="" VERTEXAI_PROJECT="" VERTEXAI_LOCATION="" VERTEXAI_MODEL_LIST="" \
# Groq
GROQ_API_KEY="" GROQ_MODEL_LIST="" GROQ_PROXY_URL="" \
# Higress
HIGRESS_API_KEY="" HIGRESS_MODEL_LIST="" HIGRESS_PROXY_URL="" \
# HuggingFace
HUGGINGFACE_API_KEY="" HUGGINGFACE_MODEL_LIST="" HUGGINGFACE_PROXY_URL="" \
# Hunyuan
HUNYUAN_API_KEY="" HUNYUAN_MODEL_LIST="" \
# InternLM
INTERNLM_API_KEY="" INTERNLM_MODEL_LIST="" \
# Jina
JINA_API_KEY="" JINA_MODEL_LIST="" JINA_PROXY_URL="" \
# Minimax
MINIMAX_API_KEY="" MINIMAX_MODEL_LIST="" \
# Mistral
MISTRAL_API_KEY="" MISTRAL_MODEL_LIST="" \
# ModelScope
MODELSCOPE_API_KEY="" MODELSCOPE_MODEL_LIST="" MODELSCOPE_PROXY_URL="" \
# Moonshot
MOONSHOT_API_KEY="" MOONSHOT_MODEL_LIST="" MOONSHOT_PROXY_URL="" \
# Nebius
NEBIUS_API_KEY="" NEBIUS_MODEL_LIST="" NEBIUS_PROXY_URL="" \
# NewAPI
NEWAPI_API_KEY="" NEWAPI_PROXY_URL="" \
# Novita
NOVITA_API_KEY="" NOVITA_MODEL_LIST="" \
# Nvidia NIM
NVIDIA_API_KEY="" NVIDIA_MODEL_LIST="" NVIDIA_PROXY_URL="" \
# Ollama
ENABLED_OLLAMA="" OLLAMA_MODEL_LIST="" OLLAMA_PROXY_URL="" \
# OpenAI
ENABLED_OPENAI="" OPENAI_API_KEY="" OPENAI_MODEL_LIST="" OPENAI_PROXY_URL="" \
# OpenRouter
OPENROUTER_API_KEY="" OPENROUTER_MODEL_LIST="" \
# Perplexity
PERPLEXITY_API_KEY="" PERPLEXITY_MODEL_LIST="" PERPLEXITY_PROXY_URL="" \
# PPIO
PPIO_API_KEY="" PPIO_MODEL_LIST="" \
# Qiniu
QINIU_API_KEY="" QINIU_MODEL_LIST="" QINIU_PROXY_URL="" \
# Qwen
QWEN_API_KEY="" QWEN_MODEL_LIST="" QWEN_PROXY_URL="" \
# SambaNova
SAMBANOVA_API_KEY="" SAMBANOVA_MODEL_LIST="" \
# Search1API
SEARCH1API_API_KEY="" SEARCH1API_MODEL_LIST="" \
✨ feat: add SenseNova (商汤) model provider (#4162) * ✨ feat: add SenseCore (商汤) model provider * 💄 style: update model list, fix `frequency_penalty`, `temperature`, `top_p` value range * 🔨 chore: add jwt api token calculate * 🔨 chore: remove `SENSECORE_API_KEY` ENV * Update authToken.ts * 🔨 chore: add debug logs * ♻️ refactor: rollback changes, remove JWT * 👷 build: add docker ENV, `SENSECORE_API_KEY` & `SENSECORE_MODEL_LIST` * 🔨 chore: cleanup * 🔨 chore: cleanup * 🔨 chore: rename `sensecore` to `sensenova` * 💄 style: update model list * 💄 style: sort model list * ✨ feat: add jwt token generator for SenseNova * ♻️ refactor: support two different type of `API TOKEN` * Update authToken.ts * 💄 style: add custom form for SenseNova * 💄 style: fix custom form calling & adjust icon size * 🐛 fix: fix CI error * 💄 style: adjust icon size * 🐛 fix: fix `sensenovaAccessKeySecret` not store in key * 🐛 fix: try to fix loading key from ENV * 🐛 fix: try to fix loading key from ENV * 🐛 fix: seems be the root cause, typo * 💄 style: remove title * 🐛 fix: fix build error * 🔨 chore: add i18n * 🐛 fix: fix PR conflicts * 🐛 fix: fix route ci error * 🐛 fix: fix PR conflicts * ♻️ refactor: move `generateJwtTokenSenseNova` to `LobeSenseNovaAI.generateJWTToken` * Update index.ts * rollback changes, submit wrong branch * 🐛 fix: fix CI error, refactor the chat webapi * ♻️ refactor: replace deprecated module `crypto-js` to `crypto-es` * Revert "♻️ refactor: replace deprecated module `crypto-js` to `crypto-es`" This reverts commit 9655c9212109a8b6b7c439062627f36342f20415. * ♻️ refactor: replace `crypto-js` to `jose`, only support ENV now (Part 1) * Revert "♻️ refactor: replace `crypto-js` to `jose`, only support ENV now (Part 1)" * ♻️ refactor: using `jose` to generate the APIToken * 🔨 chore: remove debug code * 🔨 chore: cleanup package, remove `crypto-js` * 🔨 chore: add unit test * 🔨 chore: optimize jwt generate process
2024-10-25 13:04:26 +00:00
# SenseNova
SENSENOVA_API_KEY="" SENSENOVA_MODEL_LIST="" \
# SiliconCloud
SILICONCLOUD_API_KEY="" SILICONCLOUD_MODEL_LIST="" SILICONCLOUD_PROXY_URL="" \
# Spark
SPARK_API_KEY="" SPARK_MODEL_LIST="" SPARK_PROXY_URL="" SPARK_SEARCH_MODE="" \
# Stepfun
STEPFUN_API_KEY="" STEPFUN_MODEL_LIST="" \
# Taichu
TAICHU_API_KEY="" TAICHU_MODEL_LIST="" \
# TogetherAI
TOGETHERAI_API_KEY="" TOGETHERAI_MODEL_LIST="" \
# Upstage
UPSTAGE_API_KEY="" UPSTAGE_MODEL_LIST="" \
# v0 (Vercel)
V0_API_KEY="" V0_MODEL_LIST="" \
# vLLM
VLLM_API_KEY="" VLLM_MODEL_LIST="" VLLM_PROXY_URL="" \
# Wenxin
WENXIN_API_KEY="" WENXIN_MODEL_LIST="" \
# xAI
XAI_API_KEY="" XAI_MODEL_LIST="" XAI_PROXY_URL="" \
# Xinference
XINFERENCE_API_KEY="" XINFERENCE_MODEL_LIST="" XINFERENCE_PROXY_URL="" \
# 01.AI
ZEROONE_API_KEY="" ZEROONE_MODEL_LIST="" \
# Zhipu
ZHIPU_API_KEY="" ZHIPU_MODEL_LIST="" \
# Tencent Cloud
TENCENT_CLOUD_API_KEY="" TENCENT_CLOUD_MODEL_LIST="" \
# Infini-AI
INFINIAI_API_KEY="" INFINIAI_MODEL_LIST="" \
# 302.AI
AI302_API_KEY="" AI302_MODEL_LIST="" \
# FAL
ENABLED_FAL="" FAL_API_KEY="" FAL_MODEL_LIST="" \
# BFL
BFL_API_KEY="" BFL_MODEL_LIST="" \
# Vercel AI Gateway
2025-10-30 13:02:42 +00:00
VERCELAIGATEWAY_API_KEY="" VERCELAIGATEWAY_MODEL_LIST="" \
# Cerebras
CEREBRAS_API_KEY="" CEREBRAS_MODEL_LIST=""
USER nextjs
EXPOSE 3210/tcp
ENTRYPOINT ["/bin/node"]
CMD ["/app/startServer.js"]