Skip to main content

使用命令行接口 (CLI) 进行项目部署

🌐 Project deployment with the Command Line Interface (CLI)

这是一个逐步指南,教你如何首次使用命令行接口在 Strapi Cloud 上部署你的项目。

🌐 This is a step-by-step guide for deploying your project on Strapi Cloud for the first time, using the Command Line Interface.

Prerequisites

在使用命令行接口将你的 Strapi 应用部署到 Strapi Cloud 之前,你需要具备以下先决条件:

🌐 Before you can deploy your Strapi application on Strapi Cloud using the Command Line Interface, you need to have the following prerequisites:

  • 拥有一个 Google、GitHub 或 GitLab 账号。
  • 拥有一个已创建的 Strapi 项目(参见 CMS 文档中的 从 CLI 安装),存储在本地。项目必须小于 100MB。
  • 确保你的硬盘中有可用存储空间,用于存放操作系统的临时文件夹。

登录 Strapi 云

🌐 Logging in to Strapi Cloud

  1. 打开你的终端。
  2. 导航到存储在本地电脑上的 Strapi 项目的文件夹。
  3. 输入以下命令以登录 Strapi Cloud:
yarn strapi login
  1. 在自动打开的浏览器窗口中,确认显示的代码与终端消息中写的代码相同。
  2. 仍然在浏览器窗口中,选择通过 Google、GitHub 或 GitLab 登录。窗口应在不久后确认登录成功。

部署你的项目

🌐 Deploying your project

  1. 在你的终端中,仍然在你的 Strapi 项目文件夹中,输入以下命令来部署项目:
yarn strapi deploy
  1. 在终端中关注进度条,直到确认项目已成功使用 Strapi Cloud 部署。部署项目将会在免费计划下创建一个新的 Strapi Cloud 项目。

自动部署后续更改

🌐 Automatically deploying subsequent changes

默认情况下,当使用 Cloud CLI 创建和部署项目时,每次进行更改后,都需要通过运行相应的 deploy 命令手动再次部署所有后续更改。

🌐 By default, when creating and deploying a project with the Cloud CLI, you need to manually deploy again all subsequent changes by running the corresponding deploy command everytime you make a change.

另一种选择是通过 git 仓库启用自动部署。操作步骤如下:

🌐 Another option is to enable automatic deployment through a git repository. To do so:

  1. 将你的代码托管在 git 仓库上,例如 GitHubGitLab
  2. 将你的 Strapi Cloud 项目连接到仓库(请参阅 项目设置 > 常规 中的 已连接仓库 设置)。
  3. 仍然在 项目设置 > 常规 选项卡中,勾选“在每次推送到此分支的提交时部署项目”设置框。从现在起,每当提交推送到已连接的 Git 仓库时,都会触发一次新的 Strapi Cloud 部署。
Note

自动部署与所有其他部署方法兼容,因此一旦连接了 git 仓库,你可以从 Cloud 仪表板CLI 或通过向已连接的仓库推送新提交来触发对 Strapi Cloud 的新部署。

🌐 Automatic deployment is compatible with all other deployment methods, so once a git repository is connected, you can trigger a new deployment to Strapi Cloud from the Cloud dashboard, from the CLI, or by pushing new commits to your connected repository.

⏩ 接下来做什么?

🌐 ⏩ What to do next?

既然你已经通过命令行接口部署了项目,我们鼓励你探索以下想法,以获得更完整的 Strapi Cloud 体验:

🌐 Now that you have deployed your project via the Command Line Interface, we encourage you to explore the following ideas to have an even more complete Strapi Cloud experience: