将你的 Astro 网站部署到 Zerops
Zerops 是一个以开发优先的云平台,可用于部署静态和服务端渲染的 Astro 网站。
本指南将引导你在 Zerops 上设置和部署静态 和 SSR 服务端渲染的 Astro 站点。
想在不安装或设置任何东西的情况下测试在 Zerops 上运行 Astro 吗?使用 Zerops x Astro - Static 或 Zerops x Astro - SSR 存储库,一键部署示例 Astro 站点。
在 Zerops 上运行应用程序需要两个步骤:
- 创建项目
- 触发构建和部署流水线
一个 Zerops 项目可以包含多个 Astro 站点。
在 Zerops 上部署 Astro 静态站点
段落标题 在 Zerops 上部署 Astro 静态站点创建 Astro 静态站点的项目和服务
段落标题 创建 Astro 静态站点的项目和服务可以通过 Project add 向导或使用 yaml 结构导入项目和服务:
# 参考 https://docs.zerops.io/references/import 了解更多project:  name: recipe-astroservices:  - hostname: app    type: static这将创建一个名为 recipe-astro 的项目,其中包含一个名为 app 的 Zerops 静态服务。
部署你的 Astro 静态站点
段落标题 部署你的 Astro 静态站点要告诉 Zerops 如何构建和运行你的站点,请在存储库中添加 zerops.yml 文件:
# 参考 https://docs.zerops.io/references/zeropsyml 了解更多zerops:  - setup: app    build:      base: nodejs@20      buildCommands:        - npm i        - npm build      deployFiles:        - dist/~    run:      base: static# 参考 https://docs.zerops.io/references/zeropsyml 了解更多zerops:  - setup: app    build:      base: nodejs@20      buildCommands:        - pnpm i        - pnpm build      deployFiles:        - dist/~    run:      base: static# 参考 https://docs.zerops.io/references/zeropsyml 了解更多zerops:  - setup: app    build:      base: nodejs@20      buildCommands:        - yarn        - yarn build      deployFiles:        - dist/~    run:      base: static现在你可以 使用 Zerops CLI 触发构建和部署流水线,或者通过服务详情内部将 app 服务与你的 GitHub / GitLab 存储库连接。
在 Zerops 上部署 Astro SSR 站点
段落标题 在 Zerops 上部署 Astro SSR 站点创建 Astro SSR(Node.js)的项目和服务
段落标题 创建 Astro SSR(Node.js)的项目和服务可以通过 Project add 向导或使用 yaml 结构导入项目和服务:
# 参考 https://docs.zerops.io/references/import 了解更多project:  name: recipe-astroservices:  - hostname: app    type: nodejs@20这将创建一个名为 recipe-astro 的项目,其中包含一个名为 app 的 Zerops Node.js 服务。
部署你的 Astro SSR 站点
段落标题 部署你的 Astro SSR 站点要告诉 Zerops 如何使用官方的 Astro Node.js 适配器 在 standalone 模式下构建和运行你的站点,请在存储库中添加 zerops.yml 文件:
# 参考 https://docs.zerops.io/references/zeropsyml 了解更多zerops:  - setup: app    build:      base: nodejs@20      buildCommands:        - npm i        - npm run build      deployFiles:        - dist        - package.json        - node_modules    run:      base: nodejs@20      ports:        - port: 3000          httpSupport: true      envVariables:        PORT: 3000        HOST: 0.0.0.0      start: npm start# 参考 https://docs.zerops.io/references/zeropsyml 了解更多zerops:  - setup: app    build:      base: nodejs@20      buildCommands:        - pnpm i        - pnpm run build      deployFiles:        - dist        - package.json        - node_modules    run:      base: nodejs@20      ports:        - port: 3000          httpSupport: true      envVariables:        PORT: 3000        HOST: 0.0.0.0      start: pnpm start# 参考 https://docs.zerops.io/references/zeropsyml 了解更多zerops:  - setup: app    build:      base: nodejs@20      buildCommands:        - yarn        - yarn build      deployFiles:        - dist        - package.json        - node_modules    run:      base: nodejs@20      ports:        - port: 3000          httpSupport: true      envVariables:        PORT: 3000        HOST: 0.0.0.0      start: yarn start现在你可以 使用 Zerops CLI 触发构建和部署流水线,或者通过服务详情内部将 app 服务与你的 GitHub / GitLab 存储库连接。
使用 Zerops CLI 触发流水线(zcli)
段落标题 使用 Zerops CLI 触发流水线(zcli)- 
安装 Zerops CLI。 终端窗口 # 要直接下载 zcli 二进制文件,# 请使用 https://github.com/zeropsio/zcli/releasesnpm i -g @zerops/zcli
- 
在 Zerops 中打开 Settings > Access Token Management并生成一个新的访问令牌。
- 
用以下命令使用访问令牌登录: 终端窗口 zcli login <token>
- 
导航到应用的根目录( zerops.yml所在的位置),并运行以下命令以触发部署:终端窗口 zcli push