Zerops

将您的 Nuxt 应用程序部署到 Zerops 基础设施。

Nodejs 预设SERVER_PRESET: zerops静态预设SERVER_PRESET: zerops-static

Zerops中阅读更多信息。
Nuxt x Zerops 快速运行 ✨
想在不安装或设置任何东西的情况下测试在 Zerops 上运行 Nuxt 吗?使用以下仓库Zerops x Nuxt - 静态Zerops x Nuxt - Node.js 上的 SSR您只需单击一下即可部署示例 Nuxt 应用程序。

Zerops 支持通过项目根目录中的简单配置文件部署静态和服务器端渲染的应用程序。

静态

项目和服务可以通过以下方式添加:项目添加向导或使用 YAML 结构导入

创建项目

zerops-project-import.yml
project:
  name: recipe-nuxt

services:
  - hostname: app
    type: static

这将创建一个名为recipe-nuxt的项目,其中包含一个名为app的 Zerops 静态服务。

设置 Zerops YAML

要告诉 Zerops 如何构建和运行您的应用程序,请在您的根目录中添加一个zerops.yml

zerops.yml
zerops:
  - setup: app
    build:
      base: nodejs@20
      buildCommands:
        - yarn
        - yarn nuxi generate
      deployFiles:
        - .output/public/~
    run:
      base: static

现在您可以触发使用 Zerops CLI 构建和部署管道或通过将应用程序服务与您的GitHub / GitLab在服务详细信息中连接存储库。

SSR Node.js

项目和服务可以通过以下方式添加:项目添加向导或使用 YAML 结构导入

zerops-project-import.yml
project:
  name: recipe-nuxt

services:
  - hostname: app
    type: nodejs@20

这将创建一个名为recipe-nuxt的项目,其中包含一个名为app的 Zerops Node.js 服务。

设置 Zerops YAML

要告诉 Zerops 如何构建和运行您的应用程序,请在您的根目录中添加一个zerops.yml

zerops.yml
zerops:
  - setup: nuxt
    build:
      base: nodejs@20
      buildCommands:
        - yarn
        - yarn build
      deployFiles:
        - .output/~
    run:
      base: nodejs@20
      ports:
        - port: 3000
          httpSupport: true
      start: node server/index.mjs

现在您可以触发使用 Zerops CLI 构建和部署管道或通过将应用程序服务与您的GitHub / GitLab在服务详细信息中连接存储库。

构建和部署您的应用程序

npm i -g @zerops/zcli
  • 在 Zerops 应用程序中打开设置 > 访问令牌管理并生成一个新的访问令牌。
  • 使用以下命令使用您的访问令牌登录
zcli login <token>
  • 导航到您的应用程序的根目录(zerops.yml所在的位置)并运行以下命令触发部署
zcli push

您的代码可以在每次提交或新标签时自动部署,方法是将服务与您的GitHub / GitLab存储库连接。此连接可以在服务详细信息中设置。

Zerops 文档中阅读更多信息。