|
1 | | -# TodoList应用案例 |
| 1 | +# Todolist 案例 |
2 | 2 |
|
3 | | -一款基于Node.JS的网页TodoList应用。 |
| 3 | +> 快速部署和体验Serverless架构下的 TodoList 项目 |
4 | 4 |
|
5 | | -- 基础介绍: |
6 | | - - 框架:Express |
7 | | - - 运行时:Node.js运行时 (当然,也可以选择Custom运行时,可以参考[Express的Custom案例](https://github.com/devsapp/start-web-framework/tree/master/web-framework/nodejs/express/src) ) |
8 | | -- 使用流程 |
9 | | - - 初始化项目:`s init todolist-app` |
10 | | - - 进入项目:`cd todolist-app` |
11 | | - - 部署项目:`s deploy` |
| 5 | +- [体验前准备](#体验前准备) |
| 6 | +- [代码与预览](#代码与预览) |
| 7 | +- [快速部署和体验](#快速部署和体验) |
| 8 | + - [在线快速体验](#在线快速体验) |
| 9 | + - [在本地部署体验](#在本地部署体验) |
| 10 | +- [项目使用注意事项](#项目使用注意事项) |
| 11 | +- [操作介绍](#操作介绍) |
| 12 | + |
| 13 | +## 体验前准备 |
| 14 | + |
| 15 | +该应用案例,需要您开通[阿里云函数计算](https://fcnext.console.aliyun.com/) 产品;并建议您当前的账号有一下权限存在`FCDefaultRole`。 |
| 16 | + |
| 17 | +## 代码与预览 |
| 18 | + |
| 19 | +- [:octocat: 源代码](https://github.com/devsapp/start-web-framework/tree/master/web-framework/example/todolist-app/src) |
| 20 | + |
| 21 | +## 快速部署和体验 |
| 22 | +### 在线快速体验 |
| 23 | + |
| 24 | +- 通过阿里云 **Serverless 应用中心**: 可以点击 [【🚀 部署】](https://fcnext.console.aliyun.com/applications/create?template=todolist-app) ,按照引导填入参数,快速进行部署和体验。 |
| 25 | + |
| 26 | +### 在本地部署体验 |
| 27 | + |
| 28 | +1. 下载安装 Serverless Devs:`npm install @serverless-devs/s` |
| 29 | + > 详细文档可以参考 [Serverless Devs 安装文档](https://github.com/Serverless-Devs/Serverless-Devs/blob/master/docs/zh/install.md) |
| 30 | +2. 配置密钥信息:`s config add` |
| 31 | + > 详细文档可以参考 [阿里云密钥配置文档](https://github.com/devsapp/fc/blob/main/docs/zh/config.md) |
| 32 | +3. 初始化项目:`s init todolist-app -d todolist-app` |
| 33 | +4. 进入项目并部署:`cd todolist-app && s deploy` |
| 34 | + |
| 35 | +> 在本地使用该项目时,不仅可以部署,还可以进行更多的操作,例如查看日志,查看指标,进行多种模式的调试等,这些操作详情可以参考[函数计算组件命令文档](https://github.com/devsapp/fc#%E6%96%87%E6%A1%A3%E7%9B%B8%E5%85%B3) ; |
| 36 | +
|
| 37 | +## 项目使用注意事项 |
| 38 | + |
| 39 | +1. 项目Yaml中,声明了`actions`,其对应的命令为`npm install --production`,如果在使用项目时,遇到类似找不到`npm`命令的情况,请根据自身电脑关于`nodejs`与`nmp`的配置对此出进行修改,或者手动进行依赖安装,并注释掉这`actions`部分代码; |
| 40 | +2. 目前函数计算支持的项目代码包大小为100M,如果一个完整的项目依赖包过大,可以按照以下方法进行优化和处理: |
| 41 | + - 将部分静态资源等,放在对象存储中,以降低代码包的体积; |
| 42 | + - 将 `nasConfig` 配置为 `auto`,然后基于 nas 指令将大文件(可能是训练集/依赖包)传输到 NAS 指定位置,然后配置相应的环境变量到 `s.yml` 中的函数配置中; |
| 43 | + - 将非 custom-container 的函数转换成 custom-container,这需要对代码进行一定的改造,并新增 dockerfile,然后创建这个函数(此方式冷启动时间相对其他 runtime 会有一点点的延长); |
| 44 | + |
| 45 | +## 操作介绍 |
12 | 46 |
|
13 | 47 | 更多使用内容: |
14 | 48 | - [本地构建](#本地构建) |
@@ -296,3 +330,10 @@ jobs: |
296 | 330 | ### 删除 |
297 | 331 |
|
298 | 332 | 最后,我们可以通过 `s remove service` 指令来删除上述部署的资源。 |
| 333 | + |
| 334 | + |
| 335 | +------- |
| 336 | + |
| 337 | +> - Serverless Devs 项目:https://www.github.com/serverless-devs/serverless-devs |
| 338 | +> - Serverless Devs 文档:https://www.github.com/serverless-devs/docs |
| 339 | +> - Serverless Devs 钉钉交流群:33947367 |
0 commit comments