mirror of
https://github.com/patdelphi/suanming.git
synced 2026-02-28 05:33:11 +08:00
Add frontend static file serving: 配置统一部署支持Web界面访问
This commit is contained in:
10
Dockerfile
10
Dockerfile
@@ -10,12 +10,18 @@ WORKDIR /app
|
||||
# 复制package.json和pnpm-lock.yaml
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# 安装依赖
|
||||
RUN pnpm install --frozen-lockfile --prod
|
||||
# 安装所有依赖(包括开发依赖用于构建前端)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# 复制应用代码
|
||||
COPY . .
|
||||
|
||||
# 构建前端
|
||||
RUN pnpm run build
|
||||
|
||||
# 清理开发依赖,只保留生产依赖
|
||||
RUN pnpm install --frozen-lockfile --prod
|
||||
|
||||
# 创建数据目录用于SQLite数据库
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
Build ready to start ▶️
|
||||
>> Cloning github.com/patdelphi/suanming.git commit sha 5c10fe8d3842c2ec55f29cfb9b1e7c2aefff584e into /builder/workspace
|
||||
Initialized empty Git repository in /builder/workspace/.git/
|
||||
From https://github.com/patdelphi/suanming
|
||||
* branch 5c10fe8d3842c2ec55f29cfb9b1e7c2aefff584e -> FETCH_HEAD
|
||||
HEAD is now at 5c10fe8 修复Koyeb部署问题:添加packageManager字段指定pnpm版本
|
||||
Starting Docker daemon...
|
||||
Waiting for the Docker daemon to start...
|
||||
done
|
||||
Timer: Analyzer started at 2025-08-19T09:02:34Z
|
||||
Image with name "registry01.prod.koyeb.com/k-8e751168-cf22-413e-ad8f-1dedf498563a/b5220413-de00-4b69-8514-51ef422bdcaa" not found
|
||||
Timer: Analyzer ran for 258.636887ms and ended at 2025-08-19T09:02:34Z
|
||||
Timer: Detector started at 2025-08-19T09:02:37Z
|
||||
3 of 4 buildpacks participating
|
||||
heroku/nodejs-engine 3.6.5
|
||||
heroku/nodejs-corepack 3.6.5
|
||||
heroku/nodejs-pnpm-install 3.6.5
|
||||
Timer: Detector ran for 115.628657ms and ended at 2025-08-19T09:02:37Z
|
||||
Timer: Restorer started at 2025-08-19T09:02:38Z
|
||||
Layer cache not found
|
||||
Timer: Restorer ran for 194.782532ms and ended at 2025-08-19T09:02:38Z
|
||||
Timer: Builder started at 2025-08-19T09:02:38Z
|
||||
|
||||
[1;35m## Heroku Node.js Engine[0m
|
||||
|
||||
- Checking Node.js version
|
||||
- Node.js version not specified, using `[0;33m22.x[0m`
|
||||
- Resolved Node.js version: `[0;33m22.15.1[0m`
|
||||
- Installing Node.js distribution
|
||||
- Downloading Node.js `[0;33m22.15.1 (linux-amd64)[0m` from [1;4;36mhttps://nodejs.org/download/release/v22.15.1/node-v22.15.1-linux-x64.tar.gz[0m[2;1m .[0m[2;1m.[0m[2;1m. [0m(< 0.1s)
|
||||
- Verifying checksum
|
||||
- Extracting Node.js `[0;33m22.15.1 (linux-amd64)[0m`
|
||||
- Installing Node.js `[0;33m22.15.1 (linux-amd64)[0m`[2;1m .[0m[2;1m.[0m[2;1m. [0m(< 0.1s)
|
||||
- Done (finished in 1.4s)
|
||||
|
||||
[1;35m## Heroku Node.js Corepack[0m
|
||||
|
||||
- Using Corepack version `[0;33m0.32.0[0m`
|
||||
- Found `[0;33mpackageManager[0m` set to `[0;33mpnpm@9.0.0[0m` in `[0;33mpackage.json[0m`
|
||||
- Enabling Corepack
|
||||
- Creating Corepack shims
|
||||
- Executing `[0;33m[1;36mcorepack enable --install-directory /layers/heroku_nodejs-corepack/shim/bin pnpm[0m`
|
||||
- Installing `[0;33mpnpm@9.0.0[0m`
|
||||
- Creating Corepack package manager
|
||||
- Running `[0;33m[1;36mcorepack prepare[0m`
|
||||
|
||||
Preparing pnpm@9.0.0...
|
||||
|
||||
- Done (0.4s)
|
||||
- Done (finished in 0.5s)
|
||||
|
||||
[1;35m## Heroku Node.js pnpm Install[0m
|
||||
|
||||
- Setting up pnpm dependency store
|
||||
- Creating new pnpm content-addressable store
|
||||
- Creating pnpm virtual store
|
||||
- Installing dependencies
|
||||
- Running `[0;33m[1;36mpnpm install --frozen-lockfile[0m`
|
||||
|
||||
ERR_PNPM_OUTDATED_LOCKFILE Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json
|
||||
|
||||
Note that in CI environments this setting is true by default. If you still need to run install in such cases, use "pnpm install --no-frozen-lockfile"
|
||||
|
||||
Failure reason:
|
||||
specifiers in the lockfile ({"@hookform/resolvers":"^3.10.0","@radix-ui/react-accordion":"^1.2.2","@radix-ui/react-alert-dialog":"^1.1.4","@radix-ui/react-aspect-ratio":"^1.1.1","@radix-ui/react-avatar":"^1.1.2","@radix-ui/react-checkbox":"^1.1.3","@radix-ui/react-collapsible":"^1.1.2","@radix-ui/react-context-menu":"^2.2.4","@radix-ui/react-dialog":"^1.1.4","@radix-ui/react-dropdown-menu":"^2.1.4","@radix-ui/react-hover-card":"^1.1.4","@radix-ui/react-label":"^2.1.1","@radix-ui/react-menubar":"^1.1.4","@radix-ui/react-navigation-menu":"^1.2.3","@radix-ui/react-popover":"^1.1.4","@radix-ui/react-progress":"^1.1.1","@radix-ui/react-radio-group":"^1.2.2","@radix-ui/react-scroll-area":"^1.2.2","@radix-ui/react-select":"^2.1.4","@radix-ui/react-separator":"^1.1.1","@radix-ui/react-slider":"^1.2.2","@radix-ui/react-slot":"^1.1.1","@radix-ui/react-switch":"^1.1.2","@radix-ui/react-tabs":"^1.1.2","@radix-ui/react-toast":"^1.2.4","@radix-ui/react-toggle":"^1.1.1","@radix-ui/react-toggle-group":"^1.1.1","@radix-ui/react-tooltip":"^1.1.6","@supabase/supabase-js":"^2.55.0","class-variance-authority":"^0.7.1","clsx":"^2.1.1","cmdk":"1.0.0","date-fns":"^3.0.0","embla-carousel-react":"^8.5.2","input-otp":"^1.4.2","lucide-react":"^0.364.0","next-themes":"^0.4.4","react":"^18.3.1","react-day-picker":"8.10.1","react-dom":"^18.3.1","react-hook-form":"^7.54.2","react-resizable-panels":"^2.1.7","react-router-dom":"^6","recharts":"^2.12.4","sonner":"^1.7.2","tailwind-merge":"^2.6.0","tailwindcss-animate":"^1.0.7","vaul":"^1.1.2","zod":"^3.24.1","@eslint/js":"^9.15.0","@types/node":"^22.10.7","@types/react":"^18.3.12","@types/react-dom":"^18.3.1","@types/react-router-dom":"^5","@vitejs/plugin-react":"^4.3.4","autoprefixer":"10.4.20","eslint":"^9.15.0","eslint-plugin-react-hooks":"^5.0.0","eslint-plugin-react-refresh":"^0.4.14","globals":"^15.12.0","postcss":"8.4.49","tailwindcss":"v3.4.16","typescript":"~5.6.2","typescript-eslint":"^8.15.0","vite":"^6.0.1","vite-plugin-source-info":"^1.0.0"}) don't match specs in package.json ({"@eslint/js":"^9.15.0","@types/bcryptjs":"^2.4.6","@types/cors":"^2.8.17","@types/express":"^4.17.21","@types/jsonwebtoken":"^9.0.5","@types/node":"^22.10.7","@types/react":"^18.3.12","@types/react-dom":"^18.3.1","@types/react-router-dom":"^5","@vitejs/plugin-react":"^4.3.4","autoprefixer":"10.4.20","eslint":"^9.15.0","eslint-plugin-react-hooks":"^5.0.0","eslint-plugin-react-refresh":"^0.4.14","globals":"^15.12.0","postcss":"8.4.49","tailwindcss":"v3.4.16","typescript":"~5.6.2","typescript-eslint":"^8.15.0","vite":"^6.0.1","vite-plugin-source-info":"^1.0.0","@hookform/resolvers":"^3.10.0","@radix-ui/react-accordion":"^1.2.2","@radix-ui/react-alert-dialog":"^1.1.4","@radix-ui/react-aspect-ratio":"^1.1.1","@radix-ui/react-avatar":"^1.1.2","@radix-ui/react-checkbox":"^1.1.3","@radix-ui/react-collapsible":"^1.1.2","@radix-ui/react-context-menu":"^2.2.4","@radix-ui/react-dialog":"^1.1.4","@radix-ui/react-dropdown-menu":"^2.1.4","@radix-ui/react-hover-card":"^1.1.4","@radix-ui/react-label":"^2.1.1","@radix-ui/react-menubar":"^1.1.4","@radix-ui/react-navigation-menu":"^1.2.3","@radix-ui/react-popover":"^1.1.4","@radix-ui/react-progress":"^1.1.1","@radix-ui/react-radio-group":"^1.2.2","@radix-ui/react-scroll-area":"^1.2.2","@radix-ui/react-select":"^2.1.4","@radix-ui/react-separator":"^1.1.1","@radix-ui/react-slider":"^1.2.2","@radix-ui/react-slot":"^1.1.1","@radix-ui/react-switch":"^1.1.2","@radix-ui/react-tabs":"^1.1.2","@radix-ui/react-toast":"^1.2.4","@radix-ui/react-toggle":"^1.1.1","@radix-ui/react-toggle-group":"^1.1.1","@radix-ui/react-tooltip":"^1.1.6","bcryptjs":"^2.4.3","better-sqlite3":"^12.2.0","class-variance-authority":"^0.7.1","clsx":"^2.1.1","cmdk":"1.0.0","concurrently":"^8.2.2","cors":"^2.8.5","date-fns":"^3.0.0","embla-carousel-react":"^8.5.2","express":"^4.18.2","helmet":"^7.1.0","input-otp":"^1.4.2","jsonwebtoken":"^9.0.2","lucide-react":"^0.364.0","next-themes":"^0.4.4","node-fetch":"^2.7.0","nodemon":"^3.0.2","react":"^18.3.1","react-day-picker":"8.10.1","react-dom":"^18.3.1","react-hook-form":"^7.54.2","react-resizable-panels":"^2.1.7","react-router-dom":"^6","recharts":"^2.12.4","sonner":"^1.7.2","tailwind-merge":"^2.6.0","tailwindcss-animate":"^1.0.7","vaul":"^1.1.2","zod":"^3.24.1"})
|
||||
|
||||
- Done (0.2s)
|
||||
|
||||
- [1;36mDebug Info:[0m
|
||||
- Command failed `pnpm install --frozen-lockfile`
|
||||
exit status: 1
|
||||
stdout: <see above>
|
||||
stderr: <see above>
|
||||
|
||||
[0;31m! Failed to install Node modules[0m
|
||||
[0;31m![0m
|
||||
[0;31m! The Heroku Node.js pnpm Install buildpack uses the command `[0;33mpnpm install --frozen-lockfile[0m[0;31m` to install your Node modules. This command failed and the buildpack cannot continue. This error can occur due to an unstable network connection. See the log output above for more information.[0m
|
||||
[0;31m![0m
|
||||
[0;31m! Suggestions:[0m
|
||||
[0;31m! - Ensure that this command runs locally without error (exit status = 0).[0m
|
||||
[0;31m! - Check the status of the upstream Node module repository service at https://status.npmjs.org/[0m
|
||||
[0;31m![0m
|
||||
[0;31m! Use the debug information above to troubleshoot and retry your build.[0m
|
||||
|
||||
|
||||
Timer: Builder ran for 3.429800265s and ended at 2025-08-19T09:02:42Z
|
||||
[31;1mERROR: [0mfailed to build: exit status 1
|
||||
Build failed ❌
|
||||
@@ -97,8 +97,11 @@ app.use('/api/profile', profileRoutes);
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
app.use(express.static(path.join(__dirname, '../dist')));
|
||||
|
||||
// SPA路由处理
|
||||
app.get('*', (req, res) => {
|
||||
// SPA路由处理 - 只处理非API请求
|
||||
app.get('*', (req, res, next) => {
|
||||
if (req.path.startsWith('/api')) {
|
||||
return next(); // 让后续的404处理器处理API请求
|
||||
}
|
||||
res.sendFile(path.join(__dirname, '../dist/index.html'));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user