diff --git a/src/content/docs/zh-cn/guides/deploy/seenode.mdx b/src/content/docs/zh-cn/guides/deploy/seenode.mdx new file mode 100644 index 0000000000000..f2bff0cf80854 --- /dev/null +++ b/src/content/docs/zh-cn/guides/deploy/seenode.mdx @@ -0,0 +1,102 @@ +--- +title: 将你的 Astro 站点部署到 Seenode +description: 如何在 Seenode 上将你的 Astro 网站部署到网上。 +sidebar: + label: Seenode +type: deploy +i18nReady: true +--- +import { Steps } from '@astrojs/starlight/components'; +import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro'; +import ReadMore from '~/components/ReadMore.astro'; + +[Seenode](https://seenode.com) 是一个用于构建和部署具有数据库、内置可观测性及自动扩展功能的 Web 应用部署平台。Astro 网站可通过服务端渲染(SSR)技术部署至 Seenode 平台。 + +本指南包含通过 Web 界面部署到 Seenode 的说明。 + +## 项目配置 + +### SSR 适配器 + +要在你的 Astro 项目中启用按需渲染并部署到 Seenode,使用 `astro add` 命令添加 [Node.js 适配器](/zh-cn/guides/integrations-guide/node/)。这将安装适配器并对你的 `astro.config.mjs` 文件进行相应更改。 + + + + ```shell + npx astro add node + ``` + + + ```shell + pnpm astro add node + ``` + + + ```shell + yarn astro add node + ``` + + + +安装适配器后,更新你的 `astro.config.mjs` 并按 Seenode 的要求来配置服务器: + +```js title="astro.config.mjs" ins={6-11} +import { defineConfig } from 'astro/config'; +import node from '@astrojs/node'; + +export default defineConfig({ + output: 'server', + adapter: node({ + mode: 'standalone' + }), + server: { + port: process.env.NODE_ENV === 'production' ? (Number(process.env.PORT) || 80) : 4321, + host: true + } +}); +``` + +更新你的 `package.json`,添加一个启动脚本来运行已构建的服务器: + +```json title="package.json" ins={6} +{ + "scripts": { + "dev": "astro dev", + "build": "astro build", + "preview": "astro preview", + "start": "NODE_ENV=production node ./dist/server/entry.mjs" + } +} +``` + +请参考 [Seenode 的 Astro 部署指南](https://seenode.com/docs/frameworks/javascript/astro/) 了解更多配置选项和故障排除方法。 + +## 如何部署 + +你可以通过 Web 界面连接你的 Git 仓库,将项目部署到 Seenode。 + +### Web 界面部署 + + +1. 创建一个 [Seenode 账户](https://cloud.seenode.com) 并登录。 + +2. 推送代码到你的 Git 仓库(GitHub 或 GitLab)。 + +3. 从 [Seenode 控制面板](https://cloud.seenode.com/dashboard/applications/web/create) 创建一个新的 **Web 服务** 并连接你的仓库。 + +4. Seenode 会自动检测你的 Astro 项目。配置部署设置: + - **构建命令:** `npm ci && npm run build` (或使用 `pnpm` / `yarn` 等效命令) + - **启动命令:** `npm start` + - **端口:** `80` (Web 服务必需) + +5. 选择你需要的实例大小并点击 **创建 Web 服务**。 + +6. 你的应用将被构建并部署。完成后,你将收到一个 URL 来访问你的 Astro 网站,之后你可以将你的域名绑定到该网站。 + + +## 官方资源 + +- [Seenode Cloud](https://cloud.seenode.com) — Seenode 控制面板 +- [Seenode 文档](https://seenode.com/docs) — 完整的平台文档 +- [Seenode Astro 指南](https://seenode.com/docs/frameworks/javascript/astro/) — 详细的部署指南和故障排除说明 +- [Seenode Astro 模板](https://github.com/seenode/example-astro) — 预配置的启动模板 \ No newline at end of file