Skip to content

将你的 Astro 网站部署到 Seenode

Seenode 是一个用于构建和部署 Web 应用的部署平台,它集成了数据库、可观测性和自动扩展功能。Astro 站点可以使用服务器端渲染 (SSR) 部署到 Seenode。

¥Seenode is a deployment platform for building and deploying web applications with databases, built-in observability, and auto-scaling. Astro sites can be deployed to Seenode using server-side rendering (SSR).

本指南包含通过 Web 界面部署到 Seenode 的说明。

¥This guide includes instructions for deploying to Seenode through the web interface.

¥Project Configuration

¥Adapter for SSR

要在 Astro 项目中启用按需渲染并部署到 Seenode,请使用以下 astro add 命令添加 Node.js 适配器。这将一步安装适配器并对 astro.config.mjs 文件进行适当的更改。

¥To enable on-demand rendering in your Astro project and deploy to Seenode, add the Node.js adapter with the following astro add command. This will install the adapter and make the appropriate changes to your astro.config.mjs file in one step.

终端窗口
npx astro add node

安装适配器后,请更新你的 astro.config.mjs 以配置服务器以满足 Seenode 的要求:

¥After installing the adapter, update your astro.config.mjs to configure the server for Seenode’s requirements:

astro.config.mjs
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,使其包含一个启动脚本,用于运行已构建的服务器:

¥Update your package.json to include a start script that runs the built server:

package.json
{
"scripts": {
"dev": "astro dev",
"build": "astro build",
"preview": "astro preview",
"start": "NODE_ENV=production node ./dist/server/entry.mjs"
}
}
See Seenode’s Astro deployment guide for more configuration options and troubleshooting.

¥How to Deploy

你可以通过连接 Git 仓库,经由 Web 界面部署到 Seenode。

¥You can deploy to Seenode through the web interface by connecting your Git repository.

¥Web Interface Deployment

  1. Create a Seenode account and sign in.

  2. Push your code to your Git repository (GitHub or GitLab).

  3. From the Seenode Dashboard, create a new Web Service and connect your repository.

  4. Seenode will automatically detect your Astro project. Configure the deployment settings:

    • Build Command: npm ci && npm run build (or use pnpm / yarn equivalents)
    • Start Command: npm start
    • Port: 80 (required for web services)
  5. Select your preferred instance size and click Create Web Service.

  6. Your application will be built and deployed. Once complete, you’ll receive a URL to access your live Astro site after which you can link your domain.

¥Official Resources

更多部署指南

Astro v5.16 中文网 - 粤ICP备13048890号