From ac71e77064d78ce262d72afd56ddaa68d50fdd5b Mon Sep 17 00:00:00 2001 From: huyikai Date: Wed, 8 May 2024 09:02:05 +0800 Subject: [PATCH 1/2] i18n(zh-cn): Create `zerops.mdx` --- .../docs/zh-cn/guides/deploy/zerops.mdx | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 src/content/docs/zh-cn/guides/deploy/zerops.mdx diff --git a/src/content/docs/zh-cn/guides/deploy/zerops.mdx b/src/content/docs/zh-cn/guides/deploy/zerops.mdx new file mode 100644 index 0000000000000..5560e6ae4d5d8 --- /dev/null +++ b/src/content/docs/zh-cn/guides/deploy/zerops.mdx @@ -0,0 +1,162 @@ +--- +title: 将你的 Astro 网站部署到 Zerops +description: 如何使用 Zerops 将你的 Astro 网站部署到网络。 +type: deploy +i18nReady: true +--- +import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro' +import { Steps } from '@astrojs/starlight/components'; + +[Zerops](https://zerops.io/) 是一个以开发优先的云平台,可用于部署服务端渲染的 Astro 网站。 + +本指南将指导你使用 Node.js 适配器将 Astro 项目部署到 Zerops。 + +## 前提条件 + +- **使用 [`@astrojs/node` 服务端渲染适配器](/zh-cn/guides/integrations-guide/node/) 的 Astro 项目** +- **一个 Zerops 账户** - 如果你还没有账户,可以免费[创建一个 Zerops 账户](https://zerops.io/)。 + +:::tip[从模板开始] +你可以直接将 [Zerops x Astro - Node.js 示例应用](https://github.com/zeropsio/recipe-astro-nodejs) 导入到你的 [Zerops 控制面板](https://app.zerops.io/dashboard/projects),并一键部署! +```yaml +project: + name: astro +services: + - hostname: astronode + type: nodejs@20 + buildFromGit: https://github.com/zeropsio/recipe-astro-nodejs + ports: + - port: 4321 + httpSupport: true + enableSubdomainAccess: true + minContainers: 1 +``` +::: + +## 创建一个 Zerops Node.js 项目 + +你可以通过 [Zerops `project add` 向导](https://app.zerops.io/dashboard/project-add) 为你的 Astro 网站创建一个 Node.js 服务,或者通过使用 `.yaml` 导入一个 Astro 网站。 + +以下 YAML 结构将设置一个名为 `my-astro-sites` 的项目,其中包含一个名为 `hellothere` 的 Node.js v20 服务。一个 Zerops 项目可以包含多个 Astro 应用。 + +```yaml +project: + name: my-astro-sites +services: + - hostname: hellothere + type: nodejs@20 + ports: + - port: 4321 + httpSupport: true + minContainers: 1 +``` + + +## 在 Zerops 上构建和部署你的应用 + +现在你已经在 Zerops 上准备好了一个 Node.js 服务,你需要在项目的根目录创建一个 `zerops.yml` 文件,以触发在 Zerops 上的构建和部署流程。 + +以下示例展示了如何为具有主机名 `hellothere` 的示例项目配置所需的构建和运行操作: + + + + ```yaml title="zerops.yml" + zerops: + - setup: hellothere + build: + base: nodejs@20 + buildCommands: + - npm i + - npm run build + deploy: + - dist + - package.json + - node_modules + cache: + - node_modules + - package-lock.json + run: + start: node dist/server/entry.mjs + envVariables: + HOST: 0.0.0.0 + NODE_ENV: production + ``` + + + ```yaml title="zerops.yml" + zerops: + - setup: hellothere + build: + base: nodejs@20 + buildCommands: + - pnpm i + - pnpm run build + deploy: + - dist + - package.json + - node_modules + cache: + - node_modules + - pnpm-lock.json + run: + start: node dist/server/entry.mjs + envVariables: + HOST: 0.0.0.0 + NODE_ENV: production + ``` + + + ```yaml title="zerops.yml" + zerops: + - setup: astronode + build: + base: nodejs@20 + buildCommands: + - yarn + - yarn build + deploy: + - dist + - package.json + - node_modules + cache: + - node_modules + - yarn.lock + run: + start: node dist/server/entry.mjs + envVariables: + HOST: 0.0.0.0 + NODE_ENV: production + ``` + + + +### 通过 GitHub / GitLab 触发流水线 +要在推送到分支或新发布时设置连续部署,请转到你的 Node.js 服务详情,并将你的 Zerops 服务与 GitHub 或 GitLab 仓库连接。 + +### 使用 Zerops CLI (zcli) 触发流水线 + + +1. 安装 Zerops CLI。 + ```shell + # 要直接下载 zcli 二进制文件, + # 请使用 https://github.com/zeropsio/zcli/releases + npm i -g @zerops/zcli + ``` + +2. 在 Zerops 应用中打开 [`设置 > 访问令牌管理`](https://app.zerops.io/settings/token-management) 并生成一个新的访问令牌。 + +3. 使用以下命令和你的访问令牌登录: + ```shell + zcli login + ``` + +4. 导航到你的应用根目录(`zerops.yml` 文件所在位置),运行以下命令以触发部署: + ```shell + zcli push + ``` + + +## 资源 + +- [在 3 分钟内将 Astro 部署到 Zerops](https://medium.com/@arjunaditya/how-to-deploy-astro-to-zerops-4230816a62b4) +- [创建 Zerops Node.js 服务的详细指南](https://docs.zerops.io/nodejs/how-to/create) From 67d770f3e861a1b1b830b2d9e71f0f79281779bb Mon Sep 17 00:00:00 2001 From: huyikai Date: Wed, 8 May 2024 12:48:18 +0800 Subject: [PATCH 2/2] i18n(zh-cn): Update `zerops.mdx` --- src/content/docs/zh-cn/guides/deploy/zerops.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/zh-cn/guides/deploy/zerops.mdx b/src/content/docs/zh-cn/guides/deploy/zerops.mdx index 5560e6ae4d5d8..6ad86b158bf1f 100644 --- a/src/content/docs/zh-cn/guides/deploy/zerops.mdx +++ b/src/content/docs/zh-cn/guides/deploy/zerops.mdx @@ -143,7 +143,7 @@ services: npm i -g @zerops/zcli ``` -2. 在 Zerops 应用中打开 [`设置 > 访问令牌管理`](https://app.zerops.io/settings/token-management) 并生成一个新的访问令牌。 +2. 在 Zerops 应用中打开 [`Settings > Access Token Management`](https://app.zerops.io/settings/token-management) 并生成一个新的访问令牌。 3. 使用以下命令和你的访问令牌登录: ```shell