diff --git a/content/zh/fc3/command/plan.md b/content/zh/fc3/command/plan.md index 51e0333..55910ff 100644 --- a/content/zh/fc3/command/plan.md +++ b/content/zh/fc3/command/plan.md @@ -20,10 +20,10 @@ category: '构建&部署' ### 参数解析 -| 参数全称 | 参数缩写 | Yaml 模式下必填 | 参数含义 | -| ------------- | -------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- | -| region | - | 选填 | 必填 | 地域名称,取值范围参见[函数计算开服地域](https://www.alibabacloud.com/help/zh/fc/product-overview/region-availability) | -| function-name | - | 选填 | 必填 | 函数名 | +| 参数全称 | 参数缩写 | Yaml 模式下必填 | Cli 模式下必填 | 参数含义 | +| ------------- | -------- | --------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------- | +| region | - | 选填 | 必填 | 地域名称,取值范围参见[函数计算开服地域](https://www.alibabacloud.com/help/zh/fc/product-overview/region-availability) | +| function-name | - | 选填 | 必填 | 函数名 | > 当前命令还支持部分全局参数(例如`-a/--access`, `--debug`等),详情可参考 [Serverless Devs 全局参数文档](https://serverless-devs.com/serverless-devs/command/readme#全局参数) diff --git a/content/zh/fc3/command/sync.md b/content/zh/fc3/command/sync.md index 16763c5..7d5b1ad 100644 --- a/content/zh/fc3/command/sync.md +++ b/content/zh/fc3/command/sync.md @@ -24,7 +24,7 @@ category: '其他功能' | ------------- | -------- | --------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------- | | region | - | 选填 | 必填 | 地域名称,取值范围参见[函数计算开服地域](https://www.alibabacloud.com/help/zh/fc/product-overview/region-availability) | | function-name | - | 选填 | 必填 | 函数名 | -| target-dir | - | 选填 | 选填 | 目标路径, 默认是当前目录 | +| target-dir | - | 选填 | 选填 | 目标路径, 默认是目录是 ./sync-clone | | qualifier | - | 选填 | 选填 | 版本或者别名 | > 当前命令还支持部分全局参数(例如`-a/--access`, `--debug`等),详情可参考 [Serverless Devs 全局参数文档](https://serverless-devs.com/serverless-devs/command/readme#全局参数) diff --git a/content/zh/serverless-devs/command/readme.md b/content/zh/serverless-devs/command/readme.md index 62db8b2..0eef9f5 100644 --- a/content/zh/serverless-devs/command/readme.md +++ b/content/zh/serverless-devs/command/readme.md @@ -13,8 +13,6 @@ category: '命令' - [config: 密钥配置](./config.md) - [init: 项目初始化](./init.md) - [cli: 纯命令行模式](./cli.md) - - [verify: 应用校验](./verify.md) - - [edit: 应用编辑](./edit.md) - [clean: 工具清理](./clean.md) - [component: 组件信息](./component.md) - [set: 工具配置](./set.md) @@ -27,33 +25,40 @@ Serverless Devs 可以通过`-h`唤起对应命令的帮助文档,例如查看 ```shell script $ s -h -🚀 Welcome to the Serverless Devs. +😃 Welcome to the Serverless Devs -Options - --debug Open debug model. - --skip-actions Skip the extends section. - -t, --template Specify the template file. - -a, --access Specify the access alias name. - -o, --output Specify the output format: json, yaml, raw. - -v, --version Output the version number. - -h, --help Display help for command. +Usage: s [options] [command] -Commands - config 👤 Configure venders account. - init 💞 Initializing a serverless project. - cli 🐚 Command line operation without yaml mode. - verify 🔎 Verify the application. - set 🔧 Settings for the tool. - clean 💥 Clean up the environment. - component 🔌 Installed component information. - edit 🙌 Application editing. +Options: + --debug Open debug model + --skip-actions Skip the extends section + -t, --template Specify the template file + -a, --access Specify the access alias name + -o, --output Specify the output format (choices: "default", "json", "yaml", "raw") + --output-file Specify the output file path + --env Specify the env name + --no-verify Do not verify yaml + --silent Silent mode + -v, --version Output the version number + -h, --help Display help for command +Commands: + config 👤 Configure venders account + env 🌱 Environment operation + set 🔧 Settings for the tool + registry 🚢 Serverless registry platform + preview [options] 👀 Preview Yaml render results + component 🔌 Installed component information + clean [options] 💥 Clean up the environment + init [options] 💞 Initializing a serverless project + 🧭 Custom Commands -Examples - init Perform [s init] fast experience Serverless Devs. -🧭 More information: https://github.com/Serverless-Devs/Serverless-Devs -🚀 More applications: https://registry.serverless-devs.com +🙌 Quick Start: https://docs.serverless-devs.com/quick-start +🌟 Github Repo: https://github.com/Serverless-Devs/Serverless-Devs +💡 Documentation: https://docs.serverless-devs.com +🚀 Example Projects: https://registry.serverless-devs.com +📝 Feedback: https://github.com/Serverless-Devs/Serverless-Devs/issues ``` ## 全局参数 @@ -67,14 +72,16 @@ Examples | output | o | `default` | 指定数据的输出格式 | 支持`default`, `json`, `yaml`, `raw`格式 | | version | v | - | 查看版本信息 | - | | help | h | - | 查看帮助信息 | - | +| silent | - | - | 静默模式 | 将只输出组件运行结果 | +| env | - | - | 指定环境 | 在多环境下使用 | +| output-file | - | - | 指定输出文件路径 | - | +| no-verify | - | - | 不校验`yaml`文件 | - | ## 命令详情 - [config: 密钥配置](./config.md) - [init: 项目初始化](./init.md) - [cli: 纯命令行模式](./cli.md) -- [verify: 应用校验](./verify.md) -- [edit: 应用编辑](./edit.md) - [clean: 工具清理](./clean.md) - [set: 工具配置](./set.md) - [component: 组件信息](./component.md) diff --git a/content/zh/serverless-devs/inner_env.md b/content/zh/serverless-devs/inner_env.md index 1e9d7c3..628a8d8 100644 --- a/content/zh/serverless-devs/inner_env.md +++ b/content/zh/serverless-devs/inner_env.md @@ -15,18 +15,18 @@ category: '使用文档' 如果同时存在以上三个环境变量,那个这个密钥的优先级是最高的,抛出的密钥别名为 `$system_environment_access` -### 以 `_serverless_devs_access` 结尾 -在环境变量中可以命名 key 为`*********_serverless_devs_access`,例如`default_serverless_devs_access`,value 为 JSON 字符串,例如: - - Key:`default_serverless_devs_access` +### 以 `_serverless_devs_key` 结尾 +在环境变量中可以命名 key 为`*********_serverless_devs_key`,例如`default_serverless_devs_key`,value 为 JSON 字符串,例如: + - Key:`default_serverless_devs_key` - Value:`{\"AccountID\":\"temp_accountid\",\"AccessKeyID\":\"temp_accesskeyid\",\"AccessKeySecret\":\"temp_accesskeysecret\"}` - 此时,可以在配置密钥的时候指定密钥`default_serverless_devs_access`; + 此时,可以在配置密钥的时候指定密钥`default_serverless_devs_key`; 在`s.yaml`配置如下: ```yaml edition: 1.0.0 # 命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范 name: app # 项目名称 - access: default_serverless_devs_access # 秘钥别名 + access: default_serverless_devs_key # 秘钥别名 services: fc-deploy-test: diff --git a/content/zh/serverless-devs/quick_start.md b/content/zh/serverless-devs/quick_start.md index 1f93e87..18829fa 100644 --- a/content/zh/serverless-devs/quick_start.md +++ b/content/zh/serverless-devs/quick_start.md @@ -11,10 +11,7 @@ category: '概述' - [工具安装](#工具安装) - [密钥配置](#密钥配置) -- [上手体验](#上手体验) - - [Serverless:Hello World](#serverlesshello-world) - - [人工智能:目标检测](#人工智能目标检测) - - [传统框架:基于Django的博客项目](#传统框架基于django的博客项目) +- [上手体验:快速部署一个Node应用](#上手体验快速部署一个Node应用) ## 工具安装 - 第一步:安装 Node.js(>=12.0.0) 与 NPM 包管理工具; @@ -71,9 +68,7 @@ category: '概述' > 强烈建议您遵循 [阿里云安全最佳实践](https://help.aliyun.com/document_detail/102600.html?spm=5176.2020520153.0.0.57f1336a8PQ1KR) ,使用 RAM 子用户 AccessKey 来进行 API 调用。 -## 上手体验 - -### Serverless:Hello World +## 上手体验:快速部署一个Node应用 - 执行`s`命令: ```shell script @@ -82,237 +77,125 @@ category: '概述' ``` - 填写`y`,并按回车,可以进入到创建引导部分: ```shell script - 🚀 More applications: https://registry.serverless-devs.com - + 🚀 More applications: https://registry.serverless-devs.com ? Hello Serverless for Cloud Vendors (Use arrow keys or type to search) ❯ Alibaba Cloud Serverless AWS Cloud Serverless - Baidu Cloud Serverless - Huawei Cloud Serverless Tencent Cloud Serverless + Huawei Cloud Serverless + Baidu Cloud Serverless Dev Template for Serverless Devs ``` - 此时只需要选择对应的选项,按照引导进行操作,即可。例如选择`Alibaba Cloud Serverless`,就可以看到阿里云Serverless产品下的应用模板分类: ```shell script - ? Hello, serverlesser. Which template do you like? (Use arrow keys or type to search) - ❯ Quick start [Deploy a Hello World function to FaaS] - Container example [Deploy function to FaaS with custom-container] - Web Framework [Deploy a web framework to FaaS] - Static website [Deploy a static website] - Best practice [Experience serverless project] + ? Hello, serverlesser. Which template do you like? (Use arrow keys or type to search) + ❯ Quick start + Custom runtime example + Container example + Custom domain example ``` - 此时可以继续选择某分类下的具体应用进行初始化,例如选择`Quick start`之后,可以看到该分类下的具体模板应用: ```shell script ? Which template do you like? (Use arrow keys or type to search) - ❯ [HTTP] Node.js 14 - 快速部署一个 nodejs14 http函数 - [HTTP] Python3 - 快速部署一个 python3 http函数 - [HTTP] Java8 - 快速部署一个 java8 http函数 - [HTTP] PHP7 - 快速部署一个 php http函数 - [HTTP] C++ (custom)- 快速部署一个 C++ http函数 - [Event] Node.js 14 - 快速部署一个 nodejs14 event函数 - [Event] Python3 - 快速部署一个 python3 event函数 - ... ... + ❯ Node.js + Python3 + Java + Go + Dotnet ``` - 选择`[HTTP] Node.js 14`即可完成创建,在引导的过程中,可能会出现填写项目名称以及选择密钥的过程: + + 选择`Node.js`即可完成创建,在引导的过程中,可能会出现填写项目名称以及选择密钥的过程: - 项目名称可以是:`start-fc-http-nodejs14` - 地域可以是:`cn-hangzhou` - - 服务名可以是: `hello-world-service` - 函数名可以是: `start-fc-http-nodejs14` + - nodejs 运行时可以是:`nodejs14` - 密钥可以选择我们上文中创建过的:`alibaba-access` 例如: + ```shell script 🚀 More applications: https://registry.serverless-devs.com - + ? Hello Serverless for Cloud Vendors (Use arrow keys or type to search) + ❯ Alibaba Cloud Serverless ? Hello Serverless for Cloud Vendors Alibaba Cloud Serverless ? Hello, serverlesser. Which template do you like? Quick start [Deploy a Hello World function to FaaS] - ? Which template do you like? [HTTP] Node.js 14 - - 😋 Create application command: [s init devsapp/start-fc-http-nodejs14] - - ? Please input your project name (init dir) start-fc-http-nodejs14 - ✔ file decompression completed - - Serverless Devs Application Case - - Cloud services required: - - FC : https://fc.console.aliyun.com/ - - Tips: - - FC Component: https://www.serverless-devs.com/fc/readme - 创建应用所在的地区 - ? 地域 cn-hangzhou - 服务名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间 - ? 服务名 hello-world-service - 函数名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-64 之间 - ? 函数名 start-fc-http-nodejs14 - ? please select credential alias alibaba-access - - * Before using, please check whether the actions command in Yaml file is available - * Carefully reading the notes in s.yaml is helpful for the use of the tool - * If need help in the use process, please apply to join the Dingtalk Group: 33947367 - + ? Which template do you like? Node.js + + 😋 Create application command: [s init --project start-fc3-nodejs] + + ? Please input your project name (init dir) start-fc-http-nodejs14 + Downloading[/v3/packages/start-fc3-nodejs/zipball/0.0.7]... + Download start-fc3-nodejs successfully + + Serverless Devs Application Case + + Cloud services required: + - FC : https://fc.console.aliyun.com/ + + Tips: + - FC Component: https://github.com/devsapp/fc3/blob/master/docs/zh/readme.md + 创建应用所在的地区 + ? 地域 cn-hangzhou + 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 + ? 函数名称 start-fc-http-nodejs14 + 创建应用所在的地区 + ? nodejs 运行时 nodejs14 + ? please select credential alias alibaba-access - 🏄‍ Thanks for using Serverless-Devs - 👉 You could [cd /Users/nanxuanli/work/demo/devs/start-fc-http-nodejs14] and enjoy your serverless journey! - 🧭️ If you need help for this example, you can use [s -h] after you enter folder. - 💞 Document ❤ Star: https://github.com/Serverless-Devs/Serverless-Devs - 🚀 More applications: https://registry.serverless-devs.com + * Before using, please check whether the actions command in Yaml file is available + * Carefully reading the notes in s.yaml is helpful for the use of the tool + * If need help in the use process, please apply to join the Dingtalk Group: 33947367 + - ? Do you want to deploy the project immediately? (Y/n) - ``` -- 可以看到,系统在最后有一个提醒,是否要部署该项目,此时可以输入`y`,直接进行项目的部署,稍等片刻,可以看到部署结果: - ```shell script - helloworld: - region: cn-hangzhou - service: - name: hello-world-service - function: - name: start-fc-http-nodejs14 - runtime: nodejs14 - handler: index.handler - memorySize: 128 - timeout: 60 - url: - system_url: https://start-fp-nodejs-hello-w-service-uxcvfbhdii.cn-hangzhou.fcapp.run - custom_domain: - - - domain: http://start-fc-http-nodejs14.hello-world-service.1816647648916833.cn-hangzhou.fc.devsapp.net - triggers: - - - type: http - name: httpTrigger + 🏄‍ Thanks for using Serverless-Devs + 👉 You could [cd ******/start-fc-http-nodejs14] and enjoy your serverless journey! + 🧭️ If you need help for this example, you can use [s -h] after you enter folder. + 💞 Document ❤ Star: https://github.com/Serverless-Devs/Serverless-Devs + 🚀 More applications: https://registry.serverless-devs.com ``` - 此时可以打开`domain`返回给我们的域名,进行测试。 -### 人工智能:目标检测 +- 随后进入`./start-fc-http-nodejs14`目录,使用`s deploy`进行项目部署,稍等片刻,可以看到部署结果: -- 初始化一个已有的人工智能目标检测项目:`s init devsapp/image-prediction-app`,初始化过程中可能会出现填写项目名称以及选择密钥的过程: - - 项目名称可以是:`image-prediction-app` - - 密钥可以选择我们上文中创建过的:`alibaba-access` - - 例如: ```shell script - $ s init devsapp/image-prediction-app - - 🚀 Serverless Awesome: https://github.com/Serverless-Devs/package-awesome - - ? Please input your project name (init dir) image-prediction-app - ✔ file decompression completed - ? please select credential alias alibaba-access - - ___ __ __ _______ _______ _______ - | | | |_| || _ || || | - | | | || |_| || ___|| ___| - | | | || || | __ | |___ - | | | || || || || ___| - | | | ||_|| || _ || |_| || |___ - |___| |_| |_||__| |__||_______||_______| - - - Welcome to the image-prediction-app application - This application requires to open these services: - FC : https://fc.console.aliyun.com/ - This application can help you quickly deploy the image-prediction-app project. - The application uses FC component:https://github.com/devsapp/fc - The application homepage: https://github.com/devsapp/image-prediction-app - - - 🏄‍ Thanks for using Serverless-Devs - 👉 You could [cd /Users/jiangyu/start-application/image-prediction-app] and enjoy your serverless journey! - 🧭️ If you need help for this example, you can use [s -h] after you enter folder. - 💞 Document ❤ Star:https://github.com/Serverless-Devs/Serverless-Devs - ``` -- 进入项目目录:`cd image-prediction-app` -- 通过`deploy`命令进行项目的部署: - ```shell script - Tips for next step - ====================== - * Display information of the deployed resource: s info - * Display metrics: s metrics - * Display logs: s logs - * Invoke remote function: s invoke - * Remove Service: s remove service - * Remove Function: s remove function - * Remove Trigger: s remove trigger - * Remove CustomDomain: s remove domain - - - - imageAi: - region: cn-hangzhou - url: - custom_domain: - - - domain: http://server.ai-cv-image-prediction.1583208943291465.cn-hangzhou.fc.devsapp.net + 🚀 Result for [deploy] of [hello-world-app] + ==================== + hello_world: + region: cn-hangzhou + description: hello world by serverless devs + functionName: start-fc-http-nodejs14 + handler: index.handler + internetAccess: true + memorySize: 128 + role: + runtime: nodejs14 + timeout: 30 ``` -- 此时可以打开系统分配的测试域名,并上传一张图片进行测试: - ![图片alt](https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635390067198_20211028030108110359.png) -### 传统框架:基于Django的博客项目 + 此时我们已经成功部署了一个应用。可以前往[函数计算控制台](https://fcnext.console.aliyun.com/overview)查看详情。 +- 部署成功之后,我们可以使用`s invoke`命令对该函数应用进行调用。例如: -- 初始化一个已有的基于Django的博客项目:`s init django-blog`,初始化过程中可能会出现填写项目名称以及选择密钥的过程: - - 项目名称可以是:`django-blog` - - 密钥可以选择我们上文中创建过的:`alibaba-access` - - 例如: - ```shell script - $ s init django-blog - - 🚀 Serverless Awesome: https://github.com/Serverless-Devs/package-awesome - - ? Please input your project name (init dir) django-blog - ✔ file decompression completed - ? please select credential alias alibaba-access - - ______ ___ _______ __ _ _______ _______ _______ ___ _______ _______ - | | | || _ || | | || || || _ || | | || | - | _ | | || |_| || |_| || ___|| _ || |_| || | | _ || ___| - | | | | | || || || | __ | | | || || | | | | || | __ - | |_| | ___| || || _ || || || |_| || _ | | |___ | |_| || || | - | || || _ || | | || |_| || || |_| || || || |_| | - |______| |_______||__| |__||_| |__||_______||_______||_______||_______||_______||_______| - - - Welcome to the django-blog application - This application requires to open these services: - FC : https://fc.console.aliyun.com/ - This application can help you quickly deploy the django-blog project. - The application uses Django component:https://github.com/devsapp/django - The application homepage: https://github.com/devsapp/django-blog - - * Python 3.7 is recommended; - * If the version is greater than Python 3.7: - * Operation error: ImportError: cannot import name 'metadata' from 'importlib', you can refer to: https://stackoverflow.com/questions/59216175/importerror-cannot-import-name-metadata-from-importlib - * Default information: - * Admin:/admin - * Default Admin Username: blog - * Default Admin Password: myblog12345! - - - - 🏄‍ Thanks for using Serverless-Devs - 👉 You could [cd /Users/jiangyu/django-blog] and enjoy your serverless journey! - 🧭️ If you need help for this example, you can use [s -h] after you enter folder. - 💞 Document ❤ Star:https://github.com/Serverless-Devs/Serverless-Devs - ``` -- 进入项目目录:`cd django-blog` -- 通过`deploy`命令进行项目的部署: ```shell script - Tips for next step - ====================== - * Invoke remote function: s invoke - ✔ Try container acceleration - djangoBlog: - region: cn-shenzhen - serviceName: serverless-devs-django - functionName: django - customDomains: - - http://django.serverless-devs-django.1583208943291465.cn-shenzhen.fc.devsapp.net + $ s invoke -e "{\"key\": \"val\"}" + ⌛ Steps for [invoke] of [hello-world-app] + ==================== + ========= FC invoke Logs begin ========= + FC Invoke Start RequestId: 1-6551e2b4-a057ee3a45ccf4f082ae5d2d + load code for handler:index.handler + FC Invoke End RequestId: 1-6551e2b4-a057ee3a45ccf4f082ae5d2d + + Duration: 4.14 ms, Billed Duration: 5 ms, Memory Size: 128 MB, Max Memory Used: 9.58 MB + ========= FC invoke Logs end ========= + + Invoke instanceId: c-6551e2b5-f9c5c77480384d1aa28d + Code Checksum: 11010102639495810358 + Qualifier: LATEST + RequestId: 1-6551e2b4-a057ee3a45ccf4f082ae5d2d + + Invoke Result: + val + ✔ [hello_world] completed (1.34s) ``` -- 此时可以打开系统分配的测试域名,并上传一张图片进行测试: - ![图片alt](https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1635390266827_20211028030427642356.png)