forked from withastro/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i18n(zh-cn): Create
zerops.mdx
(withastro#8212)
* i18n(zh-cn): Create `zerops.mdx` * i18n(zh-cn): Update `zerops.mdx` --------- Co-authored-by: liruifengv <liruifeng1024@gmail.com>
- Loading branch information
Showing
1 changed file
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` 的示例项目配置所需的构建和运行操作: | ||
|
||
<PackageManagerTabs> | ||
<Fragment slot="npm"> | ||
```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 | ||
``` | ||
</Fragment> | ||
<Fragment slot="pnpm"> | ||
```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 | ||
``` | ||
</Fragment> | ||
<Fragment slot="yarn"> | ||
```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 | ||
``` | ||
</Fragment> | ||
</PackageManagerTabs> | ||
|
||
### 通过 GitHub / GitLab 触发流水线 | ||
要在推送到分支或新发布时设置连续部署,请转到你的 Node.js 服务详情,并将你的 Zerops 服务与 GitHub 或 GitLab 仓库连接。 | ||
|
||
### 使用 Zerops CLI (zcli) 触发流水线 | ||
|
||
<Steps> | ||
1. 安装 Zerops CLI。 | ||
```shell | ||
# 要直接下载 zcli 二进制文件, | ||
# 请使用 https://github.com/zeropsio/zcli/releases | ||
npm i -g @zerops/zcli | ||
``` | ||
|
||
2. 在 Zerops 应用中打开 [`Settings > Access Token Management`](https://app.zerops.io/settings/token-management) 并生成一个新的访问令牌。 | ||
|
||
3. 使用以下命令和你的访问令牌登录: | ||
```shell | ||
zcli login <token> | ||
``` | ||
|
||
4. 导航到你的应用根目录(`zerops.yml` 文件所在位置),运行以下命令以触发部署: | ||
```shell | ||
zcli push | ||
``` | ||
</Steps> | ||
|
||
## 资源 | ||
|
||
- [在 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) |