跳转到内容

Serverless Devs

Terminal window
npm install @serverless-devs/s -g
s -v # 验证安装版本
Terminal window
s config add # 引导式添加密钥
s config get # 查看当前配置
s config delete # 删除失效授权

以部署一个 Node.js 环境下的 微信代理应用 为例,展示 FC3 的标准配置结构:

edition: 3.0.0
name: wechat_proxy_stack
access: "tm_aliyun" # 关联授权名称
vars: # 抽离全局变量
region: "cn-shenzhen"
resources:
wechat_proxy_app:
component: fc3
actions:
pre-deploy: # 部署前自动执行构建任务
- run: npm install
path: .
props:
region: ${vars.region}
functionName: "wechat-proxy-service"
runtime: "custom.debian10" # 使用自定义运行时
description: "wechat proxy powered by serverless devs"
timeout: 10
memorySize: 512
cpu: 0.5
code: .
customRuntimeConfig:
command:
- node
- index.js
port: 8000
environmentVariables: # 注入环境变量
PATH: /opt/nodejs20/bin:/usr/local/bin:/usr/bin:/bin
layers: # 挂载公共层(如特定版本的 Runtime)
- acs:fc:${vars.region}:official:layers/Nodejs20/versions/3
triggers: # 定义触发器
- triggerName: http_trigger
triggerType: http
triggerConfig:
authType: anonymous # 允许匿名访问
methods:
- GET
- POST

  • 初始化项目s init (支持从模版库快速创建)
  • 全量部署s deploy (自动处理资源创建与代码上传)
  • 在线调试s invoke (触发云端函数运行)
  • 日志查看s logs