diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..72977acf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,44 @@ +FROM node:18-alpine AS base +RUN apk update +RUN apk add --no-cache libc6-compat + + +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 + +COPY package.json pnpm-lock.yaml* ./ +RUN yarn global add pnpm && pnpm i --frozen-lockfile + +FROM base AS builder +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +ENV NEXT_TELEMETRY_DISABLED 1 + +RUN pnpm install + +FROM base AS runner +WORKDIR /app + +ENV NEXT_TELEMETRY_DISABLED 1 +ENV NODE_ENV production + +# Don't run production as root +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs +USER nextjs + +COPY --from=installer /app/apps/web/next.config.js . +COPY --from=installer /app/apps/web/package.json . + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ +COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static +COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public + +CMD node apps/web/server.js diff --git a/docs/next-env.d.ts b/docs/next-env.d.ts deleted file mode 100644 index 4f11a03d..00000000 --- a/docs/next-env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// - -// NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/docs/next.config.js b/docs/next.config.js deleted file mode 100644 index a64278e6..00000000 --- a/docs/next.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const withNextra = require('nextra')({ - theme: 'nextra-theme-docs', - themeConfig: './theme.config.tsx', - flexsearch: { - codeblocks: false, - }, - defaultShowCopyCode: true, -}); - -module.exports = withNextra({ reactStrictMode: true }); diff --git a/docs/package.json b/docs/package.json deleted file mode 100644 index a97d674e..00000000 --- a/docs/package.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "chatgpt-admin-web-docs", - "version": "0.0.0", - "description": "", - "main": "index.js", - "scripts": { - "docs:dev": "next dev", - "docs:start": "next start", - "docs:build": "next build" - }, - "author": "AprilNEA (https://sku.moe)", - "license": "MIT", - "dependencies": { - "next": "^13.4.10", - "nextra": "^2.13.2", - "nextra-theme-docs": "^2.13.2", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "sharp": "^0.33.0", - "swr": "^2.2.4" - }, - "devDependencies": { - "@types/node": "20.8.7", - "@types/react": "^18.0.28", - "typescript": "5.2.2" - } -} diff --git a/docs/public/images/content-safe/baidu.png b/docs/public/images/content-safe/baidu.png deleted file mode 100644 index dcc54f86..00000000 Binary files a/docs/public/images/content-safe/baidu.png and /dev/null differ diff --git a/docs/public/images/email/elastice-01.png b/docs/public/images/email/elastice-01.png deleted file mode 100644 index 9377d472..00000000 Binary files a/docs/public/images/email/elastice-01.png and /dev/null differ diff --git a/docs/public/images/email/mailgun-01.png b/docs/public/images/email/mailgun-01.png deleted file mode 100644 index 25b5b0b6..00000000 Binary files a/docs/public/images/email/mailgun-01.png and /dev/null differ diff --git a/docs/public/images/email/mailgun-02.png b/docs/public/images/email/mailgun-02.png deleted file mode 100644 index 3a0274b4..00000000 Binary files a/docs/public/images/email/mailgun-02.png and /dev/null differ diff --git a/docs/public/images/email/mailgun-03.png b/docs/public/images/email/mailgun-03.png deleted file mode 100644 index 19304739..00000000 Binary files a/docs/public/images/email/mailgun-03.png and /dev/null differ diff --git a/docs/public/images/email/mailgun-04.png b/docs/public/images/email/mailgun-04.png deleted file mode 100644 index 8cfd5f6b..00000000 Binary files a/docs/public/images/email/mailgun-04.png and /dev/null differ diff --git a/docs/public/images/email/mailgun-05.png b/docs/public/images/email/mailgun-05.png deleted file mode 100644 index 863afa28..00000000 Binary files a/docs/public/images/email/mailgun-05.png and /dev/null differ diff --git a/docs/public/images/email/mailgun-06.png b/docs/public/images/email/mailgun-06.png deleted file mode 100644 index 14bdb1cb..00000000 Binary files a/docs/public/images/email/mailgun-06.png and /dev/null differ diff --git a/docs/public/images/email/mailgun-07.png b/docs/public/images/email/mailgun-07.png deleted file mode 100644 index 7a9893e7..00000000 Binary files a/docs/public/images/email/mailgun-07.png and /dev/null differ diff --git a/docs/public/images/email/wechat-01.png b/docs/public/images/email/wechat-01.png deleted file mode 100644 index 10602144..00000000 Binary files a/docs/public/images/email/wechat-01.png and /dev/null differ diff --git a/docs/public/images/pay/xunhu-01.png b/docs/public/images/pay/xunhu-01.png deleted file mode 100644 index 35f88b5e..00000000 Binary files a/docs/public/images/pay/xunhu-01.png and /dev/null differ diff --git a/docs/public/images/sms/unisms-01.png b/docs/public/images/sms/unisms-01.png deleted file mode 100644 index dc7a56e4..00000000 Binary files a/docs/public/images/sms/unisms-01.png and /dev/null differ diff --git a/docs/src/components/sponsors.tsx b/docs/src/components/sponsors.tsx deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/src/hooks/use-stars.ts b/docs/src/hooks/use-stars.ts deleted file mode 100644 index 872a23c6..00000000 --- a/docs/src/hooks/use-stars.ts +++ /dev/null @@ -1,10 +0,0 @@ -import useSWR from 'swr/immutable'; - -export const useStars = () => { - const { data } = useSWR<{ - stargazers_count: number; - }>('https://api.github.com/repos/AprilNEA/next-online-judge', (url: string) => - fetch(url).then((res) => res.json()), - ); - return data?.stargazers_count; -}; diff --git a/docs/src/pages/_meta.json b/docs/src/pages/_meta.json deleted file mode 100644 index fb6c6aa3..00000000 --- a/docs/src/pages/_meta.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "index": "主页", - "quickstart": "快速开始", - "upgrade": { - "title": "升级" - }, - "development": { - "title": "开发" - }, - "-- More": { - "type": "separator", - "title": "More" - }, - "github_link": { - "title": "Github ↗", - "href": "https://github.com/AprilNEA/ChatGPT-Admin-Web", - "newWindow": true - } -} - diff --git a/docs/src/pages/development/_meta.json b/docs/src/pages/development/_meta.json deleted file mode 100644 index a17df95b..00000000 --- a/docs/src/pages/development/_meta.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "auth": "认证部分" -} diff --git a/docs/src/pages/development/auth.md b/docs/src/pages/development/auth.md deleted file mode 100644 index 80d2a2bd..00000000 --- a/docs/src/pages/development/auth.md +++ /dev/null @@ -1,38 +0,0 @@ -# 认证部分 - -```mermaid -graph TD - - %% 开始节点 - start(用户选择) - - %% 密码方式 - start --> passwordChoice[选择密码方式] - - passwordChoice --> passwordLogin[密码登录] - passwordLogin --> endPasswordLogin[登录完成] - - %% 验证码方式 - start --> codeChoice[选择验证码方式] - - codeChoice --> codeLogin[验证码登录] - codeLogin --> checkPasswordCode[检查是否设置密码] - - - codeChoice --> codeRegister[验证码注册] - codeRegister --> checkPasswordCode[检查是否设置密码] - checkPasswordCode --> setPasswordCodeRegister[提示设置密码] - checkPasswordCode --> endCodeRegister[注册完成] - - %% 微信扫码方式 - start --> wechatChoice[选择微信扫码方式] - - wechatChoice --> wechatLogin[微信扫码登录] - wechatLogin --> ifBind[判断是否绑定] - ifBind --> alreadyBind[已绑定] - ifBind --> notBind[未绑定] - alreadyBind --> endWechatLogin[登录完成] - notBind --> bind[绑定手机或邮箱] - bind --> setPasswordWechat[设置密码] - setPasswordWechat --> endWechatRegister[注册完成] -``` diff --git a/docs/src/pages/index.mdx b/docs/src/pages/index.mdx deleted file mode 100644 index 36d78e77..00000000 --- a/docs/src/pages/index.mdx +++ /dev/null @@ -1,64 +0,0 @@ -import {useSSG} from 'nextra/ssg' -import { Cards, Card } from 'nextra/components' - -export const getStaticProps = async ({params}) => { - const githubRepo = await fetch(`https://api.github.com/repos/AprilNEA/ChatGPT-Admin-Web`) - .then(res => res.json()) - const afdianPage = await fetch(`https://afdian.net/api/creator/get-top-sponsors?user_id=612f691e0f1611ee97c152540025c377`) - .then(res => res.json()) - return { - props: { - // We add an `ssg` field to the page props, - // which will be provided to the Nextra `useSSG` hook. - ssg: { - stars: githubRepo?.stargazers_count ?? 0, - sponsors: afdianPage.data.list - } - }, - // The page will be considered as stale and regenerated every 60 seconds. - revalidate: 60 - } -} - -export const Sponsors = () => { - const {sponsors} = useSSG() - return
{sponsors.map((sponsor) => ( - {sponsor.name} - ))}
-} - -export const Stars = () => { - // Get the data from SSG, and render it as a component. - const {stars} = useSSG() - return {stars} -} - - - -# ChatGPT-Admin-Web - -这是一个由 [ChatGPT-Next-Web](https://github.com/Yidadaa/ChatGPT-Next-Web) 二次开发的项目。 - - - - - - -## 捐赠 - -[GitHub Sponsor](https://github.com/sponsors/AprilNEA) | [爱发电](https://afdian.net/a/aprilnea) - -ChatGPT-Admin-Web has stars on GitHub! - -## 致谢 - - diff --git a/docs/src/pages/quickstart.mdx b/docs/src/pages/quickstart.mdx deleted file mode 100644 index ef4f7b4a..00000000 --- a/docs/src/pages/quickstart.mdx +++ /dev/null @@ -1,131 +0,0 @@ -import { Callout, Steps } from 'nextra/components' - -## 快速开始 - - **Prerequisite** You should have installed Node.js (version 18.10.0 or - higher). - - - - ### 克隆项目并安装依赖 - - ```bash - git clone https://github.com/AprilNEA/ChatGPT-Admin-Web.git - cd ChatGPT-Admin-Web - pnpm install - ``` - > pnpm 安装:`npm i -g pnpm` - - ### 初始化数据库 - - 设置`DATABASE_URL`环境变量,例如: - ```bash - export DATABASE_URL=postgres://postgres:your_password@localhost:5432/postgres - ``` - > 可通过 Docker 快速启动一个 PostgreSQL 数据库 - > - > `docker run -itd --name caw -e POSTGRES_PASSWORD=your_password -p 5432:5432 -d postgres` - - 在项目根目录运行: - - ```bash - pnpm run db:init - ``` - - 你会看见如下输出,则表明数据库已经初始化成功: - - ```bash - > chatgpt-admin-web@3.1.0 db:init /path/to/ChatGPT-Admin-Web - > prisma db push && prisma db seed - - Environment variables loaded from .env - Prisma schema loaded from prisma/schema.prisma - Datasource "db": PostgreSQL database "postgres", schema "public" at "localhost:5434" - - 🚀 Your database is now in sync with your Prisma schema. Done in 245ms - - ✔ Generated Prisma Client (v5.3.1) to ./prisma/client in 297ms - - Environment variables loaded from .env - Running seed command `ts-node prisma/seed.ts` ... - { - models: {count: 2}, - categories: {count: 1}, - products: {count: 1}, - limits: {count: 1} - } - - 🌱 The seed command has been executed. - - ``` - - 设置`REDIS_URL`环境变量,例如: - ```bash - export REDIS_URL=redis://localhost:6379/0 - ``` - > 可通过 Docker 快速启动一个 Redis 数据库 - > - > `docker run -p 6379:6379 -d redis/redis-stack:latest` - - - ### 启动项目 - ```bash - pnpm run start - ``` - - 项目默认运行在 `http://localhost:3000`。 - - 首次运行项目会自动生成`config.json`, 并导入`DATABASE_URL`和`REDIS_URL`环境变量,后续更改可直接修改`config.json`。 - - - Dashboard is coming soon. - - - ~~首次打开应自动转跳`http://localhost:3000/install`设置管理员账户和密码,设置成功后即可登录。~~ - - - -## 配置 - - - 邮件服务仅 Resend 通过测试。 - 短信服务仅 UniSMS 通过测试。 - 支付服务仅 Xunhu 通过测试。 - - -```json -{ - ...// 自动生成部分 - - "openai": { - "baseUrl": "https://api.openai.com/v1", - "keys": [ - "fff" - ] - }, - "email": { - "use": "resend", - "domain": "example.com", - "resend": { - "apiKey": "fff" - } - }, - "sms": { - "use": "uni", - "uni": { - "signature": "XX科技", - "apiKey": "ffffff" - } - }, - "payment": { - "use": "xunhu", - "xunhu": { - "wapName": "XX科技", - "appId": "ffffff", - "appSecret": "ffffff", - "notifyUrl": "https://example.com", - "returnUrl": "https://example.com" - } - } -} -``` diff --git a/docs/src/pages/upgrade/log.mdx b/docs/src/pages/upgrade/log.mdx deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/src/pages/upgrade/v1tov3.mdx b/docs/src/pages/upgrade/v1tov3.mdx deleted file mode 100644 index f001ba4f..00000000 --- a/docs/src/pages/upgrade/v1tov3.mdx +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: '从v1升级' -description: '' ---- diff --git a/docs/theme.config.tsx b/docs/theme.config.tsx deleted file mode 100644 index e1f38852..00000000 --- a/docs/theme.config.tsx +++ /dev/null @@ -1,13 +0,0 @@ -export default { - logo: ChatGPT Admin Web, - project: { - link: 'https://github.com/AprilNEA/ChatGPT-Admin-Web', - }, - sidebar: { - defaultMenuCollapseLevel: 1, - toggleButton: true, - }, - toc: { - backToTop: true, - }, -}; diff --git a/docs/tsconfig.json b/docs/tsconfig.json deleted file mode 100644 index 01167281..00000000 --- a/docs/tsconfig.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "compilerOptions": { - "target": "es2018", - "module": "commonjs", - "declaration": true, - "outDir": "./dist", - "strict": true, - "jsx": "preserve", - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "allowJs": false, - "skipLibCheck": true, - "noEmit": true, - "incremental": true, - "moduleResolution": "node", - "isolatedModules": true - }, - "include": [ - "./**/*.ts", - "./**/*.tsx", - "theme.config.tsx" - ], - "ts-node": { - "swc": true - }, - "mdx": { - "plugins": [ - [ - "remark-frontmatter", - [ - "yaml" - ] - ] - ] - }, - "exclude": [ - "node_modules" - ] -}