├── .github └── workflows │ └── publish_app.yaml ├── .gitignore ├── .signore ├── README.md ├── auto-publish.py ├── custom-container ├── golang │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ ├── Dockerfile │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── main.go │ │ ├── readme.md │ │ └── s.yaml │ └── version.md ├── java │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ ├── Dockerfile │ │ │ ├── pom.xml │ │ │ ├── settings.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ └── demo │ │ │ │ │ │ ├── DemoApplication.java │ │ │ │ │ │ └── controller │ │ │ │ │ │ └── helloController.java │ │ │ │ └── resources │ │ │ │ │ └── application.properties │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── demo │ │ │ │ └── DemoApplicationTests.java │ │ ├── readme.md │ │ └── s.yaml │ └── version.md ├── nodejs │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ ├── Dockerfile │ │ │ ├── package.json │ │ │ └── server.js │ │ ├── readme.md │ │ └── s.yaml │ └── version.md └── python │ ├── hook │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ ├── code │ │ ├── Dockerfile │ │ └── app.py │ ├── readme.md │ └── s.yaml │ └── version.md ├── custom ├── golang │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ ├── go.mod │ │ │ └── main.go │ │ ├── readme.md │ │ └── s.yaml │ └── version.md ├── java │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ ├── .fcignore │ │ │ ├── pom.xml │ │ │ └── src │ │ │ │ ├── main │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ └── demo │ │ │ │ │ │ ├── DemoApplication.java │ │ │ │ │ │ └── controller │ │ │ │ │ │ └── helloController.java │ │ │ │ └── resources │ │ │ │ │ └── application.properties │ │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── demo │ │ │ │ └── DemoApplicationTests.java │ │ ├── readme.md │ │ └── s.yaml │ └── version.md ├── nodejs │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ ├── package.json │ │ │ └── server.js │ │ ├── readme.md │ │ └── s.yaml │ └── version.md └── python │ ├── hook │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ ├── code │ │ ├── requirements.txt │ │ └── server.py │ ├── readme.md │ └── s.yaml │ └── version.md ├── fc-custom-domain ├── hook │ └── index.js ├── publish.yaml ├── readme.md ├── src │ ├── code │ │ └── index.js │ ├── readme.md │ └── s.yaml └── version.md ├── fc-dotnetcore ├── hello-world │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── HelloWorldApp │ │ │ ├── HelloWorldApp.csproj │ │ │ └── Program.cs │ │ ├── readme.md │ │ └── s.yaml │ └── version.md └── simple-http │ ├── hook │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ ├── HelloWorldApp │ │ ├── HelloWorldApp.csproj │ │ └── Program.cs │ ├── readme.md │ └── s.yaml │ └── version.md ├── fc-golang ├── hello-world │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ ├── go.mod │ │ │ └── main.go │ │ ├── readme.md │ │ └── s.yaml │ └── version.md └── simple-http │ ├── hook │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ ├── code │ │ ├── go.mod │ │ └── main.go │ ├── readme.md │ └── s.yaml │ └── version.md ├── fc-java ├── hello-world │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── pom.xml │ │ ├── readme.md │ │ ├── s.yaml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── example │ │ │ └── App.java │ └── version.md └── simple-http │ ├── hook │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ ├── pom.xml │ ├── readme.md │ ├── s.yaml │ └── src │ │ └── main │ │ └── java │ │ └── example │ │ ├── App.java │ │ ├── HTTPTriggerEvent.java │ │ └── HTTPTriggerResponse.java │ └── version.md ├── fc-node ├── exec-command │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ └── index.js │ │ ├── readme.md │ │ └── s.yaml │ └── version.md ├── hello-world-es │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ └── index.mjs │ │ ├── readme.md │ │ └── s.yaml │ └── version.md ├── hello-world │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ └── index.js │ │ ├── readme.md │ │ └── s.yaml │ └── version.md ├── json-event │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ └── index.js │ │ ├── readme.md │ │ └── s.yaml │ └── version.md ├── oss-event │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ └── index.js │ │ ├── readme.md │ │ └── s.yaml │ └── version.md ├── simple-http │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ └── index.js │ │ ├── readme.md │ │ └── s.yaml │ └── version.md └── start-mcp-server │ ├── hook │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ ├── .signore │ ├── build.yaml │ ├── code │ │ ├── .fcignore │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── check_node_version.mjs │ │ ├── package-lock.json │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ ├── tsconfig.json │ │ └── webpack.config.js │ ├── readme.md │ └── s.yaml │ └── version.md ├── fc-php ├── hello-world │ ├── hook │ │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ │ ├── code │ │ │ └── index.php │ │ ├── readme.md │ │ └── s.yaml │ └── version.md └── simple-http │ ├── hook │ └── index.js │ ├── publish.yaml │ ├── readme.md │ ├── src │ ├── code │ │ └── index.php │ ├── readme.md │ └── s.yaml │ └── version.md └── fc-python ├── hello-world ├── hook │ └── index.js ├── publish.yaml ├── readme.md ├── src │ ├── code │ │ └── index.py │ ├── readme.md │ └── s.yaml └── version.md └── simple-http ├── hook └── index.js ├── publish.yaml ├── readme.md ├── src ├── code │ └── index.py ├── readme.md └── s.yaml └── version.md /.github/workflows/publish_app.yaml: -------------------------------------------------------------------------------- 1 | name: auto try publish all 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | env: 8 | REGISTRY_TOKEN: ${{secrets.ALIBABA_REGISTRY_V3_PUBLISH_TOKEN}} 9 | 10 | jobs: 11 | auto-publish: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: actions/setup-node@v2 16 | with: 17 | node-version: 16 18 | registry-url: https://registry.npmjs.org/ 19 | - uses: actions/setup-python@v5 20 | with: 21 | python-version: '3.10' 22 | - name: install s 23 | run: | 24 | npm i @serverless-devs/s -g 25 | - name: publish 26 | run: | 27 | python auto-publish.py -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | target 3 | replace-committers.sh 4 | fc-dotnetcore/*/src/HelloWorldApp/obj 5 | fc-dotnetcore/*/src/HelloWorldApp/bin 6 | .idea 7 | */*/src/s_dev.yaml -------------------------------------------------------------------------------- /.signore: -------------------------------------------------------------------------------- 1 | **tests** 2 | .husky 3 | .s 4 | .github 5 | .idea 6 | .vscode 7 | .DS_Store 8 | .git 9 | .env 10 | node_modules 11 | LICENSE 12 | package-lock.json 13 | .prettierrc.js 14 | .prettierignore 15 | .eslintrc.js 16 | .eslintignore 17 | .editorconfig 18 | .gitignore 19 | makefile 20 | README.md 21 | docs 22 | replace-committers.sh 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 阿里云函数计算:FC 3.0 案例 2 | 3 | ![图片alt](https://serverless-article-picture.oss-cn-hangzhou.aliyuncs.com/1638188206727_20211129121647053051.png) 4 | 5 | > 注意,如果您使用函数计算2.0,请切换到 V2 分支 6 | 7 | ## 本地快速体验 8 | 9 | 通过该应用,您可以简单快速的创建一个 FC 案例到阿里云函数计算服务。 10 | 11 | - 下载命令行工具:`npm install -g @serverless-devs/s` 12 | - 初始化一个模版项目:`s init start-fc3-python -d start-fc3-python` 13 | - 进入项目后部署项目:`cd start-fc3-python && s deploy` 14 | 15 | ## 包含内容 16 | 17 | ### 标准 Runtime 18 | 19 | #### nodejs 20 | 21 | - [start-fc3-nodejs-es](./fc-node/hello-world-es/src) (ES Module) 22 | 23 | - [start-fc3-nodejs](./fc-node/hello-world/src) (CommonJS Module) 24 | 25 | - [start-fc3-nodejs-json](./fc-node/json-event/src) 26 | 27 | - [start-fc3-nodejs-oss](./fc-node/oss-event/src) 28 | 29 | - [start-fc3-nodejs-exec](./fc-node/exec-command/src) 30 | 31 | - [start-fc3-nodejs-http](./fc-node/simple-http/src) 32 | 33 | #### python 34 | 35 | - [start-fc3-python](./fc-python/hello-world/src) 36 | 37 | - [start-fc3-python-http](./fc-python/simple-http/src) 38 | 39 | #### java 40 | 41 | - [start-fc3-java](./fc-java/hello-world/src) 42 | 43 | - [start-fc3-java-http](./fc-java/simple-http/src) 44 | 45 | #### golang 46 | 47 | - [start-fc3-golang](./fc-golang/hello-world/src) 48 | 49 | - [start-fc3-golang-http](./fc-golang/simple-http/src) 50 | 51 | #### php 52 | 53 | - [start-fc3-php](./fc-php/hello-world/src/) 54 | 55 | - [start-fc3-php-http](./fc-php/simple-http/src/) 56 | 57 | #### .Net 58 | 59 | - [start-fc3-dotnetcore](./fc-dotnetcore/hello-world/src) 60 | 61 | - [start-fc3-dotnetcore-http](./fc-dotnetcore/simple-http/src) 62 | 63 | ### Custom Runtime 64 | 65 | - [start-fc3-custom-nodejs](./custom/nodejs/src) 66 | 67 | - [start-fc3-custom-python](./custom/python/src) 68 | 69 | - [start-fc3-custom-golang](./custom/golang/src) 70 | 71 | - [start-fc3-custom-java](./custom/java/src) 72 | 73 | ### Custom Container 74 | 75 | - [start-fc3-custom-container-nodejs](./custom-container/nodejs/src) 76 | 77 | - [start-fc3-custom-container-python](./custom-container/python/src) 78 | 79 | - [start-fc3-custom-container-golang](./custom-container/golang/src) 80 | 81 | - [start-fc3-custom-container-java](./custom-container/java/src) 82 | 83 | ## Custom Domain 84 | 85 | - [fc-custom-domain](./fc-custom-domain/src) 86 | 87 | --- 88 | > 89 | > - Serverless Devs 项目: 90 | > - Serverless Devs 钉钉交流群:33947367 91 | -------------------------------------------------------------------------------- /auto-publish.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | import os 4 | import subprocess 5 | 6 | os.system("s registry login --token {}".format(os.environ["REGISTRY_TOKEN"])) 7 | 8 | 9 | def search_publish_yaml(directory): 10 | succ_app_list = [] 11 | for root, dirs, files in os.walk(directory): 12 | if "publish.yaml" in files: 13 | d = os.path.join(os.getcwd(), root) 14 | d = d.replace("/./", "/") 15 | cmd = ["s", "registry", "publish"] 16 | result = subprocess.run( 17 | cmd, cwd=d, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True 18 | ) 19 | exit_code = result.returncode 20 | print("publish {}; =====> ExitCode={}".format(d, exit_code)) 21 | 22 | if exit_code != 0: 23 | errMsg = "" 24 | errMsg += result.stdout 25 | errMsg += result.stderr 26 | if "当前版本号应当大于前一次版本号" not in errMsg: 27 | print(errMsg) 28 | else: 29 | succ_app_list.append(d) 30 | 31 | print("\n\npublish success app list:\n") 32 | for item in succ_app_list: 33 | print("{} published success".format(item)) 34 | 35 | 36 | # 在当前目录递归搜索 37 | search_publish_yaml(".") 38 | -------------------------------------------------------------------------------- /custom-container/golang/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /custom-container/golang/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-custom-container-golang 5 | Version: 0.0.12 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Custom Container Golang 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-hangzhou 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-hangzhou 38 | - cn-shanghai 39 | - cn-beijing 40 | - cn-zhangjiakou 41 | - cn-shenzhen 42 | - cn-hongkong 43 | - ap-southeast-1 44 | - ap-northeast-1 45 | - us-east-1 46 | - us-west-1 47 | functionName: 48 | title: 函数名称 49 | type: string 50 | default: start-golang-${default-suffix} 51 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 52 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 53 | runtime: 54 | title: 运行时 55 | type: string 56 | default: custom-container 57 | description: 创建应用所在的地区 58 | enum: 59 | - custom-container 60 | acrImage: 61 | title: ACR 镜像 62 | type: string 63 | default: "registry.${vars.region}.aliyuncs.com//:" 64 | description: 阿里云容器镜像服务ACR的镜像地址,格式为 registry.${vars.region}.aliyuncs.com//: 65 | -------------------------------------------------------------------------------- /custom-container/golang/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /custom-container/golang/src/code/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.20-bullseye 2 | 3 | 4 | RUN mkdir -p /usr/src/app 5 | WORKDIR /usr/src 6 | COPY . . 7 | 8 | RUN go env -w GO111MODULE=on 9 | RUN go env -w GOPROXY=https://goproxy.cn,direct 10 | RUN go mod tidy 11 | RUN go build -o bootstrap main.go 12 | RUN cp bootstrap /usr/src/app/bootstrap 13 | ENTRYPOINT ["/usr/src/app/bootstrap"] -------------------------------------------------------------------------------- /custom-container/golang/src/code/go.mod: -------------------------------------------------------------------------------- 1 | module example.com/m 2 | 3 | go 1.20 4 | 5 | require github.com/gin-gonic/gin v1.9.1 6 | 7 | require ( 8 | github.com/bytedance/sonic v1.9.1 // indirect 9 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect 10 | github.com/gabriel-vasile/mimetype v1.4.2 // indirect 11 | github.com/gin-contrib/sse v0.1.0 // indirect 12 | github.com/go-playground/locales v0.14.1 // indirect 13 | github.com/go-playground/universal-translator v0.18.1 // indirect 14 | github.com/go-playground/validator/v10 v10.14.0 // indirect 15 | github.com/goccy/go-json v0.10.2 // indirect 16 | github.com/json-iterator/go v1.1.12 // indirect 17 | github.com/klauspost/cpuid/v2 v2.2.4 // indirect 18 | github.com/leodido/go-urn v1.2.4 // indirect 19 | github.com/mattn/go-isatty v0.0.19 // indirect 20 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 21 | github.com/modern-go/reflect2 v1.0.2 // indirect 22 | github.com/pelletier/go-toml/v2 v2.0.8 // indirect 23 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect 24 | github.com/ugorji/go/codec v1.2.11 // indirect 25 | golang.org/x/arch v0.3.0 // indirect 26 | golang.org/x/crypto v0.9.0 // indirect 27 | golang.org/x/net v0.10.0 // indirect 28 | golang.org/x/sys v0.8.0 // indirect 29 | golang.org/x/text v0.9.0 // indirect 30 | google.golang.org/protobuf v1.30.0 // indirect 31 | gopkg.in/yaml.v3 v3.0.1 // indirect 32 | ) 33 | -------------------------------------------------------------------------------- /custom-container/golang/src/code/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io/ioutil" 5 | 6 | "github.com/gin-gonic/gin" 7 | ) 8 | 9 | func main() { 10 | r := gin.Default() 11 | r.POST("/invoke", func(c *gin.Context) { 12 | bodyBytes, err := ioutil.ReadAll(c.Request.Body) 13 | if err != nil { 14 | panic(err) 15 | } 16 | c.JSON(200, gin.H{ 17 | "message": "hello " + string(bodyBytes), 18 | }) 19 | }) 20 | 21 | r.POST("/initialize", func(c *gin.Context) { 22 | c.JSON(200, gin.H{ 23 | "message": "initialize ok", 24 | }) 25 | }) 26 | 27 | r.GET("/", func(c *gin.Context) { 28 | c.JSON(200, gin.H{ 29 | "message": "hello world", 30 | }) 31 | }) 32 | // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080") 33 | r.Run() 34 | } 35 | -------------------------------------------------------------------------------- /custom-container/golang/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - component: fc3 build --dockerfile ./code/Dockerfile 19 | props: 20 | region: ${vars.region} 21 | functionName: "{{ functionName }}" 22 | runtime: "{{ runtime }}" 23 | description: 'hello world by serverless devs' 24 | timeout: 60 25 | memorySize: 512 26 | cpu: 0.5 27 | diskSize: 512 28 | code: ./code 29 | customContainerConfig: 30 | image: "{{ acrImage }}" 31 | port: 8080 32 | # triggers: 33 | # - triggerName: httpTrigger # 触发器名称 34 | # triggerType: http # 触发器类型 35 | # description: 'xxxx' 36 | # qualifier: LATEST # 触发服务的版本 37 | # triggerConfig: 38 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 39 | # disableURLInternet: false # 是否禁用公网访问 URL 40 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 41 | # - GET 42 | # - POST -------------------------------------------------------------------------------- /custom-container/golang/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /custom-container/java/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /custom-container/java/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-custom-container-java 5 | Version: 0.0.12 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Custom Container Java 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-hangzhou 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-hangzhou 38 | - cn-shanghai 39 | - cn-beijing 40 | - cn-zhangjiakou 41 | - cn-shenzhen 42 | - cn-hongkong 43 | - ap-southeast-1 44 | - ap-northeast-1 45 | - us-east-1 46 | - us-west-1 47 | functionName: 48 | title: 函数名称 49 | type: string 50 | default: start-java-${default-suffix} 51 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 52 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 53 | runtime: 54 | title: 运行时 55 | type: string 56 | default: custom-container 57 | description: 创建应用所在的地区 58 | enum: 59 | - custom-container 60 | acrImage: 61 | title: ACR 镜像 62 | type: string 63 | default: "registry.${vars.region}.aliyuncs.com//:" 64 | description: 阿里云容器镜像服务ACR的镜像地址,格式为 registry.${vars.region}.aliyuncs.com//: 65 | 66 | -------------------------------------------------------------------------------- /custom-container/java/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /custom-container/java/src/code/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rsonghuster/openjdk8:stretch 2 | 3 | RUN mkdir -p /usr/app 4 | WORKDIR /usr/app 5 | COPY src ./src 6 | COPY pom.xml ./pom.xml 7 | COPY settings.xml /usr/share/maven/conf/settings.xml 8 | RUN mvn package -DskipTests 9 | ENTRYPOINT ["java", "-jar", "/usr/app/target/demo-0.1.0.jar"] -------------------------------------------------------------------------------- /custom-container/java/src/code/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework 7 | demo 8 | 0.1.0 9 | jar 10 | Spring Boot Docker 11 | Getting started with Spring Boot and Docker 12 | 13 | 14 | org.springframework.boot 15 | spring-boot-starter-parent 16 | 2.1.8.RELEASE 17 | 18 | 19 | 20 | 21 | springio 22 | 1.8 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-maven-plugin 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-web 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /custom-container/java/src/code/src/main/java/com/example/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @SpringBootApplication 9 | @RestController 10 | public class DemoApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(DemoApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /custom-container/java/src/code/src/main/java/com/example/demo/controller/helloController.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.controller; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import java.util.Map; 5 | import org.springframework.boot.SpringApplication; 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RestController; 9 | import org.springframework.web.bind.annotation.RequestHeader; 10 | import org.springframework.web.bind.annotation.RequestBody; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | 13 | @RestController 14 | public class helloController { 15 | @RequestMapping("/") 16 | public String sayHello() { 17 | return "hello world!"; 18 | } 19 | 20 | // FC Initializer: /initialize will be called when the FC functions are 21 | // initialized by 22 | // API calls, Function updates or FC internal system upgrades 23 | @PostMapping("/initialize") 24 | public String fcEventInitialize(@RequestHeader Map headers) { 25 | String fcRequestID = headers.get("x-fc-request-id"); 26 | System.out.println("Initialized, request ID: " + fcRequestID); 27 | return "Hello Spring Boot, from FC Event function initializer!\nPowered by FunctionCompute custom-container runtime\n" 28 | + "RequestID: " + fcRequestID + "\n"; 29 | } 30 | 31 | // FC Event function: 32 | // Invoke handler: /invoke will be called when the FC function responds to an 33 | // event (e.g. API call or OSS PutObject) 34 | @PostMapping("/invoke") 35 | public String fcEventInvoke(@RequestHeader Map headers, @RequestBody String event) { 36 | String fcRequestID = headers.get("x-fc-request-id"); 37 | System.out.println("hello world!"); 38 | System.out.println(event); 39 | System.out.println("Invoke finished, request ID: " + fcRequestID); 40 | return "hello world!"; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /custom-container/java/src/code/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=9000 2 | # server.servlet.context-path=/2016-08-15/proxy/$ServiceName/$functionName/ -------------------------------------------------------------------------------- /custom-container/java/src/code/src/test/java/com/example/demo/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | import static org.junit.Assert.assertEquals; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class DemoApplicationTests { 13 | 14 | @Test 15 | public void testSayHello() { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /custom-container/java/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - component: fc3 build --dockerfile ./code/Dockerfile 19 | props: 20 | region: ${vars.region} 21 | functionName: "{{ functionName }}" 22 | runtime: "{{ runtime }}" 23 | description: 'hello world by serverless devs' 24 | timeout: 30 25 | memorySize: 512 26 | cpu: 0.5 27 | diskSize: 512 28 | code: ./code 29 | customContainerConfig: 30 | image: "{{ acrImage }}" 31 | # triggers: 32 | # - triggerName: httpTrigger # 触发器名称 33 | # triggerType: http # 触发器类型 34 | # description: 'xxxx' 35 | # qualifier: LATEST # 触发服务的版本 36 | # triggerConfig: 37 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 38 | # disableURLInternet: false # 是否禁用公网访问 URL 39 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 40 | # - GET 41 | # - POST 42 | -------------------------------------------------------------------------------- /custom-container/java/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /custom-container/nodejs/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /custom-container/nodejs/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-custom-container-nodejs 5 | Version: 0.0.12 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Custom Container Node.js 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-hangzhou 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-hangzhou 38 | - cn-shanghai 39 | - cn-beijing 40 | - cn-zhangjiakou 41 | - cn-shenzhen 42 | - cn-hongkong 43 | - ap-southeast-1 44 | - ap-northeast-1 45 | - us-east-1 46 | - us-west-1 47 | functionName: 48 | title: 函数名称 49 | type: string 50 | default: start-nodejs-${default-suffix} 51 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 52 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 53 | runtime: 54 | title: 运行时 55 | type: string 56 | default: custom-container 57 | description: 创建应用所在的地区 58 | enum: 59 | - custom-container 60 | acrImage: 61 | title: ACR 镜像 62 | type: string 63 | default: "registry.${vars.region}.aliyuncs.com//:" 64 | description: 阿里云容器镜像服务ACR的镜像地址,格式为 registry.${vars.region}.aliyuncs.com//: 65 | 66 | -------------------------------------------------------------------------------- /custom-container/nodejs/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /custom-container/nodejs/src/code/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:14-buster 2 | 3 | # Create app directory 4 | WORKDIR /usr/src/ 5 | 6 | # Install app dependencies 7 | # A wildcard is used to ensure both package.json AND package-lock.json are copied 8 | # where available (npm@5+) 9 | COPY package*.json ./ 10 | 11 | RUN npm install 12 | # If you are building your code for production 13 | # RUN npm ci --only=production 14 | 15 | # Bundle app source 16 | COPY . . 17 | 18 | EXPOSE 9000 19 | ENTRYPOINT [ "node", "server.js" ] -------------------------------------------------------------------------------- /custom-container/nodejs/src/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docker_web_app", 3 | "version": "1.0.0", 4 | "description": "Node.js on Docker", 5 | "author": "First Last ", 6 | "main": "server.js", 7 | "scripts": { 8 | "start": "node server.js" 9 | }, 10 | "dependencies": { 11 | "express": "^4.16.1" 12 | } 13 | } -------------------------------------------------------------------------------- /custom-container/nodejs/src/code/server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // Constants 4 | const PORT = 9000; 5 | const HOST = '0.0.0.0'; 6 | const REQUEST_ID_HEADER = 'x-fc-request-id' 7 | 8 | const express = require('express'); 9 | const app = express(); 10 | app.use(express.raw()); 11 | 12 | app.post('/initialize', (req, res) => { 13 | // console.log(JSON.stringify(req.headers)); 14 | var rid = req.headers[REQUEST_ID_HEADER] 15 | console.log(`FC Initialize Start RequestId: ${rid}`) 16 | // do your things 17 | res.send('Hello FunctionCompute, initialize \n'); 18 | console.log(`FC Initialize End RequestId: ${rid}`) 19 | }); 20 | 21 | // invocation 22 | app.post('/invoke', (req, res) => { 23 | // console.log(JSON.stringify(req.headers)); 24 | var rid = req.headers[REQUEST_ID_HEADER] 25 | console.log(`FC Invoke Start RequestId: ${rid}`) 26 | console.log("hello world!") 27 | // try { 28 | // // get body to do your things 29 | // var bodyStr = req.body.toString(); 30 | // console.log(bodyStr); 31 | // JSON.parse(bodyStr); 32 | // } catch (e) { 33 | // console.error(e.stack || e); 34 | // return res.status(404).send(e.stack || e); 35 | // } 36 | 37 | res.send('OK'); 38 | console.log(`FC Invoke End RequestId: ${rid}`) 39 | }); 40 | 41 | var server = app.listen(PORT, HOST); 42 | console.log(`Running on http://${HOST}:${PORT}`); 43 | 44 | server.timeout = 0; // never timeout 45 | server.keepAliveTimeout = 0; // keepalive, never timeout -------------------------------------------------------------------------------- /custom-container/nodejs/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - component: fc3 build --dockerfile ./code/Dockerfile 19 | props: 20 | region: ${vars.region} 21 | functionName: "{{ functionName }}" 22 | runtime: "{{ runtime }}" 23 | description: 'hello world by serverless devs' 24 | timeout: 30 25 | memorySize: 512 26 | cpu: 0.5 27 | diskSize: 512 28 | code: ./code 29 | customContainerConfig: 30 | image: "{{ acrImage }}" 31 | # triggers: 32 | # - triggerName: httpTrigger # 触发器名称 33 | # triggerType: http # 触发器类型 34 | # description: 'xxxx' 35 | # qualifier: LATEST # 触发服务的版本 36 | # triggerConfig: 37 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 38 | # disableURLInternet: false # 是否禁用公网访问 URL 39 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 40 | # - GET 41 | # - POST 42 | -------------------------------------------------------------------------------- /custom-container/nodejs/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /custom-container/python/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /custom-container/python/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-custom-container-python 5 | Version: 0.0.12 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Custom Container Python 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-hangzhou 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-hangzhou 38 | - cn-shanghai 39 | - cn-beijing 40 | - cn-zhangjiakou 41 | - cn-shenzhen 42 | - cn-hongkong 43 | - ap-southeast-1 44 | - ap-northeast-1 45 | - us-east-1 46 | - us-west-1 47 | functionName: 48 | title: 函数名称 49 | type: string 50 | default: start-python-${default-suffix} 51 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 52 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 53 | runtime: 54 | title: 运行时 55 | type: string 56 | default: custom-container 57 | description: 创建应用所在的地区 58 | enum: 59 | - custom-container 60 | acrImage: 61 | title: ACR 镜像 62 | type: string 63 | default: "registry.${vars.region}.aliyuncs.com//:" 64 | description: 阿里云容器镜像服务ACR的镜像地址,格式为 registry.${vars.region}.aliyuncs.com//: 65 | 66 | -------------------------------------------------------------------------------- /custom-container/python/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /custom-container/python/src/code/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.9-buster 2 | 3 | WORKDIR /usr/src 4 | RUN pip install flask -i https://pypi.tuna.tsinghua.edu.cn/simple 5 | COPY . . 6 | 7 | CMD [ "python", "-u", "/usr/src/app.py" ] 8 | -------------------------------------------------------------------------------- /custom-container/python/src/code/app.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import sys 3 | import traceback 4 | from flask import Flask, request 5 | 6 | app = Flask(__name__) 7 | 8 | logging.basicConfig(level=logging.INFO) 9 | 10 | 11 | @app.route("/initialize", methods=["POST"]) 12 | def initialize(): 13 | # See FC docs for all the HTTP headers: https://www.alibabacloud.com/help/doc-detail/132044.htm#common-headers 14 | request_id = request.headers.get("x-fc-request-id", "") 15 | print("FC Initialize Start RequestId: " + request_id) 16 | 17 | # do your things 18 | # Use the following code to get temporary credentials 19 | # access_key_id = request.headers['x-fc-access-key-id'] 20 | # access_key_secret = request.headers['x-fc-access-key-secret'] 21 | # access_security_token = request.headers['x-fc-security-token'] 22 | 23 | print("FC Initialize End RequestId: " + request_id) 24 | return "Function is initialized, request_id: " + request_id + "\n" 25 | 26 | 27 | @app.route("/invoke", methods=["POST"]) 28 | def invoke(): 29 | # See FC docs for all the HTTP headers: https://www.alibabacloud.com/help/doc-detail/132044.htm#common-headers 30 | request_id = request.headers.get("x-fc-request-id", "") 31 | print("FC Invoke Start RequestId: " + request_id) 32 | 33 | print("hello world!") 34 | # Get function input, data type is bytes, convert as needed 35 | # event = request.get_data() 36 | # event_str = event.decode("utf-8") 37 | 38 | # Use the following code to get temporary STS credentials to access Alibaba Cloud services 39 | # access_key_id = request.headers['x-fc-access-key-id'] 40 | # access_key_secret = request.headers['x-fc-access-key-secret'] 41 | # access_security_token = request.headers['x-fc-security-token'] 42 | 43 | print("FC Invoke End RequestId: " + request_id) 44 | return "hello world!" 45 | 46 | 47 | if __name__ == "__main__": 48 | app.run(debug=False, host="0.0.0.0", port=9000) 49 | -------------------------------------------------------------------------------- /custom-container/python/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - component: fc3 build --dockerfile ./code/Dockerfile 19 | props: 20 | region: ${vars.region} 21 | functionName: "{{ functionName }}" 22 | runtime: "{{ runtime }}" 23 | description: 'hello world by serverless devs' 24 | timeout: 30 25 | memorySize: 512 26 | cpu: 0.5 27 | diskSize: 512 28 | code: ./code 29 | customContainerConfig: 30 | image: "{{ acrImage }}" 31 | # triggers: 32 | # - triggerName: httpTrigger # 触发器名称 33 | # triggerType: http # 触发器类型 34 | # description: 'xxxx' 35 | # qualifier: LATEST # 触发服务的版本 36 | # triggerConfig: 37 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 38 | # disableURLInternet: false # 是否禁用公网访问 URL 39 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 40 | # - GET 41 | # - POST 42 | -------------------------------------------------------------------------------- /custom-container/python/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /custom/golang/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /custom/golang/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-custom-golang 5 | Version: 0.0.9 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Custom Golang 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-huhehaote 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-beijing 38 | - cn-hangzhou 39 | - cn-shanghai 40 | - cn-qingdao 41 | - cn-zhangjiakou 42 | - cn-huhehaote 43 | - cn-shenzhen 44 | - cn-chengdu 45 | - cn-hongkong 46 | - ap-southeast-1 47 | - ap-southeast-2 48 | - ap-southeast-3 49 | - ap-southeast-5 50 | - ap-northeast-1 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-golang-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: golang 运行时 64 | type: string 65 | default: custom 66 | description: 创建应用所在的地区 67 | enum: 68 | - custom 69 | - custom.debian10 70 | -------------------------------------------------------------------------------- /custom/golang/src/code/go.mod: -------------------------------------------------------------------------------- 1 | module example.com/m 2 | 3 | go 1.17 4 | 5 | require github.com/awesome-fc/golang-runtime v0.0.0-20230119040721-3f65ab4b97d3 6 | 7 | require ( 8 | github.com/sirupsen/logrus v1.9.0 // indirect 9 | github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 // indirect 10 | golang.org/x/sys v0.4.0 // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /custom/golang/src/code/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | gr "github.com/awesome-fc/golang-runtime" 7 | ) 8 | 9 | func initialize(ctx *gr.FCContext) error { 10 | ctx.GetLogger().Infoln("init golang!") 11 | return nil 12 | } 13 | 14 | func handler(ctx *gr.FCContext, event []byte) ([]byte, error) { 15 | fcLogger := ctx.GetLogger() 16 | _, err := json.Marshal(ctx) 17 | if err != nil { 18 | fcLogger.Error("error:", err) 19 | } 20 | fcLogger.Infof("hello golang!") 21 | fcLogger.Infof("hello golang2!") 22 | return event, nil 23 | } 24 | 25 | func main() { 26 | gr.Start(handler, initialize) 27 | } 28 | -------------------------------------------------------------------------------- /custom/golang/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - run: GO111MODULE=on go mod tidy 19 | path: ./code 20 | - run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go 21 | path: ./code 22 | props: 23 | region: ${vars.region} 24 | functionName: "{{ functionName }}" 25 | runtime: "{{ runtime }}" 26 | description: 'hello world by serverless devs' 27 | timeout: 10 28 | memorySize: 512 29 | cpu: 0.5 30 | diskSize: 512 31 | code: ./code/target 32 | customRuntimeConfig: 33 | command: 34 | - '/code/main' 35 | port: 9000 36 | # triggers: 37 | # - triggerName: httpTrigger # 触发器名称 38 | # triggerType: http # 触发器类型 39 | # description: 'xxxx' 40 | # qualifier: LATEST # 触发服务的版本 41 | # triggerConfig: 42 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 43 | # disableURLInternet: false # 是否禁用公网访问 URL 44 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 45 | # - GET 46 | # - POST -------------------------------------------------------------------------------- /custom/golang/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /custom/java/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /custom/java/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-custom-java 5 | Version: 0.0.9 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Custom Java 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-huhehaote 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-beijing 38 | - cn-hangzhou 39 | - cn-shanghai 40 | - cn-qingdao 41 | - cn-zhangjiakou 42 | - cn-huhehaote 43 | - cn-shenzhen 44 | - cn-chengdu 45 | - cn-hongkong 46 | - ap-southeast-1 47 | - ap-southeast-2 48 | - ap-southeast-3 49 | - ap-southeast-5 50 | - ap-northeast-1 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-java-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: java 运行时 64 | type: string 65 | default: custom 66 | description: 创建应用所在的地区 67 | enum: 68 | - custom 69 | -------------------------------------------------------------------------------- /custom/java/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /custom/java/src/code/.fcignore: -------------------------------------------------------------------------------- 1 | src 2 | pom.xml 3 | .fcignore -------------------------------------------------------------------------------- /custom/java/src/code/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.1.8.RELEASE 9 | 10 | 11 | 12 | com.example 13 | demo 14 | 0.0.1-SNAPSHOT 15 | demo 16 | Demo project for Spring Boot 17 | 18 | 19 | 1.8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-test 31 | test 32 | 33 | 34 | 35 | 36 | ${project.name} 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-maven-plugin 41 | 42 | true 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /custom/java/src/code/src/main/java/com/example/demo/DemoApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @SpringBootApplication 9 | @RestController 10 | public class DemoApplication { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(DemoApplication.class, args); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /custom/java/src/code/src/main/java/com/example/demo/controller/helloController.java: -------------------------------------------------------------------------------- 1 | package com.example.demo.controller; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class helloController { 10 | @RequestMapping("/invoke") 11 | public String sayHello() { 12 | System.out.println("hello world!"); 13 | return "hello world!"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /custom/java/src/code/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.port=9000 2 | # server.servlet.context-path=/2016-08-15/proxy/$ServiceName/$functionName/ -------------------------------------------------------------------------------- /custom/java/src/code/src/test/java/com/example/demo/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.demo; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | import static org.junit.Assert.assertEquals; 9 | 10 | @RunWith(SpringRunner.class) 11 | @SpringBootTest 12 | public class DemoApplicationTests { 13 | 14 | @Test 15 | public void testSayHello() { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /custom/java/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-custom-java 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个 Custom Java 的 Hello World 函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/custom/java/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-custom-java) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-custom-java) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-custom-java -d start-fc3-custom-java` 65 | - 进入项目,并进行项目部署:`cd start-fc3-custom-java && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /custom/java/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - run: mvn package -DskipTests 19 | path: ./code 20 | props: 21 | region: ${vars.region} 22 | functionName: "{{ functionName }}" 23 | runtime: "{{ runtime }}" 24 | description: 'hello world by serverless devs' 25 | timeout: 30 26 | memorySize: 512 27 | cpu: 0.5 28 | diskSize: 512 29 | code: ./code 30 | customRuntimeConfig: 31 | command: 32 | - java 33 | args: 34 | - '-jar' 35 | - 'target/demo.jar' 36 | # environmentVariables: #环境变量 37 | # PATH: /opt/java8/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin 38 | # JAVA_HOME: /opt/java8 39 | # layers: 40 | # - acs:fc:${vars.region}:official:layers/Java8/versions/1 41 | # triggers: 42 | # - triggerName: httpTrigger # 触发器名称 43 | # triggerType: http # 触发器类型 44 | # description: 'xxxx' 45 | # qualifier: LATEST # 触发服务的版本 46 | # triggerConfig: 47 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 48 | # disableURLInternet: false # 是否禁用公网访问 URL 49 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 50 | # - GET 51 | # - POST 52 | -------------------------------------------------------------------------------- /custom/java/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /custom/nodejs/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /custom/nodejs/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-custom-nodejs 5 | Version: 0.0.8 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Custom Node.js 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-huhehaote 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-beijing 38 | - cn-hangzhou 39 | - cn-shanghai 40 | - cn-qingdao 41 | - cn-zhangjiakou 42 | - cn-huhehaote 43 | - cn-shenzhen 44 | - cn-chengdu 45 | - cn-hongkong 46 | - ap-southeast-1 47 | - ap-southeast-2 48 | - ap-southeast-3 49 | - ap-southeast-5 50 | - ap-northeast-1 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-nodejs-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: nodejs 运行时 64 | type: string 65 | default: custom 66 | description: 创建应用所在的地区 67 | enum: 68 | - custom 69 | - custom.debian10 70 | -------------------------------------------------------------------------------- /custom/nodejs/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /custom/nodejs/src/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "express": "^4.17.1" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /custom/nodejs/src/code/server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // Constants 4 | const PORT = 9000; 5 | const HOST = '0.0.0.0'; 6 | const REQUEST_ID_HEADER = 'x-fc-request-id' 7 | 8 | const express = require('express'); 9 | const app = express(); 10 | app.use(express.raw()); 11 | 12 | app.post('/initialize', (req, res) => { 13 | // console.log(JSON.stringify(req.headers)); 14 | var rid = req.headers[REQUEST_ID_HEADER] 15 | console.log(`FC Initialize Start RequestId: ${rid}`) 16 | // do your things 17 | res.send('Hello FunctionCompute, initialize \n'); 18 | console.log(`FC Initialize End RequestId: ${rid}`) 19 | }); 20 | 21 | // invocation 22 | app.post('/invoke', (req, res) => { 23 | // console.log(JSON.stringify(req.headers)); 24 | var rid = req.headers[REQUEST_ID_HEADER] 25 | console.log(`FC Invoke Start RequestId: ${rid}`) 26 | console.log("hello world!"); 27 | res.send('hello world!'); 28 | console.log(`FC Invoke End RequestId: ${rid}`) 29 | }); 30 | 31 | var server = app.listen(PORT, HOST); 32 | console.log(`Running on http://${HOST}:${PORT}`); 33 | 34 | server.timeout = 0; // never timeout 35 | server.keepAliveTimeout = 0; // keepalive, never timeout -------------------------------------------------------------------------------- /custom/nodejs/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-deploy: # 在deploy之前运行 18 | - run: npm install 19 | path: ./code 20 | props: 21 | region: ${vars.region} 22 | functionName: "{{ functionName }}" 23 | runtime: "{{ runtime }}" 24 | description: 'hello world by serverless devs' 25 | timeout: 10 26 | memorySize: 512 27 | cpu: 0.5 28 | diskSize: 512 29 | code: ./code 30 | customRuntimeConfig: 31 | command: 32 | - node 33 | - server.js 34 | port: 9000 35 | environmentVariables: #环境变量 36 | PATH: /opt/nodejs16/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin 37 | layers: 38 | - acs:fc:${vars.region}:official:layers/Nodejs16/versions/1 39 | # triggers: 40 | # - triggerName: httpTrigger # 触发器名称 41 | # triggerType: http # 触发器类型 42 | # description: 'xxxx' 43 | # qualifier: LATEST # 触发服务的版本 44 | # triggerConfig: 45 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 46 | # disableURLInternet: false # 是否禁用公网访问 URL 47 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 48 | # - GET 49 | # - POST -------------------------------------------------------------------------------- /custom/nodejs/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /custom/python/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /custom/python/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-custom-python 5 | Version: 0.0.11 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Custom Python 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-huhehaote 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-beijing 38 | - cn-hangzhou 39 | - cn-shanghai 40 | - cn-qingdao 41 | - cn-zhangjiakou 42 | - cn-huhehaote 43 | - cn-shenzhen 44 | - cn-chengdu 45 | - cn-hongkong 46 | - ap-southeast-1 47 | - ap-southeast-2 48 | - ap-southeast-3 49 | - ap-southeast-5 50 | - ap-northeast-1 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-python-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | -------------------------------------------------------------------------------- /custom/python/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /custom/python/src/code/requirements.txt: -------------------------------------------------------------------------------- 1 | flask==2.2.5 -------------------------------------------------------------------------------- /custom/python/src/code/server.py: -------------------------------------------------------------------------------- 1 | from flask.logging import default_handler 2 | import time 3 | from flask import Flask 4 | from flask import request 5 | import json 6 | import sys 7 | import traceback 8 | import logging 9 | 10 | 11 | log = logging.getLogger("werkzeug") 12 | log.setLevel(logging.ERROR) 13 | 14 | 15 | app = Flask(__name__) 16 | 17 | 18 | REQUEST_ID_HEADER = "x-fc-request-id" 19 | 20 | 21 | @app.route("/initialize", methods=["POST"]) 22 | def init_invoke(): 23 | rid = request.headers.get(REQUEST_ID_HEADER) 24 | print("FC Initialize Start RequestId: " + rid) 25 | # do your things 26 | 27 | print("FC Initialize End RequestId: " + rid) 28 | return "OK" 29 | 30 | 31 | @app.route("/invoke", methods=["POST"]) 32 | def event_invoke(): 33 | rid = request.headers.get(REQUEST_ID_HEADER) 34 | print("FC Invoke Start RequestId: " + rid) 35 | 36 | print("hello world!") 37 | 38 | print("FC Invoke End RequestId: " + rid) 39 | 40 | return "hello world!" 41 | 42 | 43 | if __name__ == "__main__": 44 | app.run(host="0.0.0.0", port=9000, threaded=True) 45 | -------------------------------------------------------------------------------- /custom/python/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - component: fc3 build 19 | props: 20 | region: ${vars.region} 21 | functionName: "{{ functionName }}" 22 | runtime: custom.debian10 23 | description: 'hello world by serverless devs' 24 | timeout: 10 25 | memorySize: 512 26 | cpu: 0.5 27 | diskSize: 512 28 | code: ./code 29 | customRuntimeConfig: 30 | port: 9000 31 | command: 32 | - python3 33 | - server.py 34 | environmentVariables: 35 | PYTHONPATH: /code/python 36 | PATH: /code/python/bin:/var/fc/lang/python3.10/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin 37 | # triggers: 38 | # - triggerName: httpTrigger # 触发器名称 39 | # triggerType: http # 触发器类型 40 | # description: 'xxxx' 41 | # qualifier: LATEST # 触发服务的版本 42 | # triggerConfig: 43 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 44 | # disableURLInternet: false # 是否禁用公网访问 URL 45 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 46 | # - GET 47 | # - POST -------------------------------------------------------------------------------- /custom/python/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-custom-domain/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-custom-domain/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-custom-domain 5 | Version: 0.0.6 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个带有自定义域名的 Node.JS 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | Parameters: 22 | type: object 23 | additionalProperties: false # 不允许增加其他属性 24 | required: # 必填项 25 | - region 26 | - functionName 27 | - runtime 28 | properties: 29 | region: 30 | title: 地域 31 | type: string 32 | default: cn-huhehaote 33 | description: 创建应用所在的地区 34 | enum: 35 | - cn-beijing 36 | - cn-hangzhou 37 | - cn-shanghai 38 | - cn-qingdao 39 | - cn-zhangjiakou 40 | - cn-huhehaote 41 | - cn-shenzhen 42 | - cn-chengdu 43 | - cn-hongkong 44 | - ap-southeast-1 45 | - ap-southeast-2 46 | - ap-southeast-3 47 | - ap-southeast-5 48 | - ap-southeast-7 49 | - ap-northeast-1 50 | - ap-northeast-2 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-nodejs-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: nodejs 运行时 64 | type: string 65 | default: nodejs14 66 | description: 创建应用所在的地区 67 | enum: 68 | - nodejs8 69 | - nodejs10 70 | - nodejs12 71 | - nodejs14 72 | - nodejs16 73 | -------------------------------------------------------------------------------- /fc-custom-domain/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-custom-domain/src/code/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.handler = function (event, context, callback) { 4 | console.log(event); 5 | callback(null, `hello, event = ${event.toString()}`); 6 | }; -------------------------------------------------------------------------------- /fc-custom-domain/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} 18 | functionName: "{{ functionName }}" 19 | description: 'hello world by serverless devs' 20 | runtime: "{{ runtime }}" 21 | code: ./code 22 | handler: index.handler 23 | memorySize: 128 24 | timeout: 30 25 | # triggers: 26 | # - triggerName: httpTrigger # 触发器名称 27 | # triggerType: http # 触发器类型 28 | # description: 'xxxx' 29 | # qualifier: LATEST # 触发服务的版本 30 | # triggerConfig: 31 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 32 | # disableURLInternet: false # 是否禁用公网访问 URL 33 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 34 | # - GET 35 | # - POST 36 | 37 | test-fc-domain: 38 | component: fc3-domain 39 | props: # 组件的属性值 40 | region: ${vars.region} 41 | domainName: auto # 使用 auto 自动获取一个临时测试域名, 生产请务必使用自己的域名 42 | protocol: HTTP # HTTP | HTTPS | HTTP,HTTPS 43 | routeConfig: 44 | routes: 45 | - functionName: ${resources.hello_world.props.functionName} 46 | methods: 47 | - GET 48 | - POST 49 | path: /a 50 | qualifier: LATEST 51 | -------------------------------------------------------------------------------- /fc-custom-domain/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-dotnetcore/hello-world/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-dotnetcore/hello-world/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-dotnetcore 5 | Version: 0.0.9 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 .NET 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-huhehaote 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-beijing 38 | - cn-hangzhou 39 | - cn-shanghai 40 | - cn-qingdao 41 | - cn-zhangjiakou 42 | - cn-huhehaote 43 | - cn-shenzhen 44 | - cn-chengdu 45 | - cn-hongkong 46 | - ap-southeast-1 47 | - ap-southeast-2 48 | - ap-southeast-3 49 | - ap-southeast-5 50 | - ap-northeast-1 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-dotnetcore-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: dotnetcore 运行时 64 | type: string 65 | default: dotnetcore3.1 66 | description: 创建应用所在的地区 67 | enum: 68 | - dotnetcore3.1 69 | -------------------------------------------------------------------------------- /fc-dotnetcore/hello-world/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-dotnetcore/hello-world/src/HelloWorldApp/HelloWorldApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /fc-dotnetcore/hello-world/src/HelloWorldApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using System.Threading.Tasks; 5 | using Aliyun.Serverless.Core; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace Example 9 | { 10 | public class Hello 11 | { 12 | public async Task StreamHandler(Stream input, IFcContext context) 13 | { 14 | string strtxt="hello world! 你好,世界!"; 15 | byte[] bytetxt = Encoding.UTF8.GetBytes(strtxt); 16 | Console.WriteLine(strtxt); 17 | MemoryStream ms = new MemoryStream(); 18 | await input.CopyToAsync(ms); 19 | ms.Write(bytetxt, 0, bytetxt.Length); 20 | return ms; 21 | } 22 | 23 | static void Main(string[] args){} 24 | } 25 | } -------------------------------------------------------------------------------- /fc-dotnetcore/hello-world/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-dotnetcore 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个 .NET 的 Hello World 函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-dotnetcore/hello-world/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-dotnetcore) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-dotnetcore) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-dotnetcore -d start-fc3-dotnetcore` 65 | - 进入项目,并进行项目部署:`cd start-fc3-dotnetcore && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-dotnetcore/hello-world/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - run: dotnet publish -c Release -o ./target 19 | path: ./HelloWorldApp 20 | props: 21 | region: ${vars.region} 22 | functionName: "{{ functionName }}" 23 | description: 'hello world by serverless devs' 24 | runtime: "{{ runtime }}" 25 | code: ./HelloWorldApp/target/ 26 | handler: HelloWorldApp::Example.Hello::StreamHandler 27 | memorySize: 128 28 | timeout: 10 29 | # triggers: 30 | # - triggerName: httpTrigger # 触发器名称 31 | # triggerType: http # 触发器类型 32 | # description: 'xxxx' 33 | # qualifier: LATEST # 触发服务的版本 34 | # triggerConfig: 35 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 36 | # disableURLInternet: false # 是否禁用公网访问 URL 37 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 38 | # - GET 39 | # - POST -------------------------------------------------------------------------------- /fc-dotnetcore/hello-world/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-dotnetcore/simple-http/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-dotnetcore/simple-http/publish.yaml: -------------------------------------------------------------------------------- 1 | Edition: 3.0.0 2 | Type: Project 3 | Name: start-fc3-dotnetcore-http 4 | Version: 0.0.5 5 | Provider: 6 | - 阿里云 7 | Description: 快速部署一个具有 http 触发器的 .NET 函数到阿里云函数计算。 8 | HomePage: https://github.com/devsapp/start-fc 9 | Tags: 10 | - 函数计算 11 | - 你好世界 12 | - 新手入门 13 | Category: 新手入门 14 | Service: 15 | 函数计算: 16 | Authorities: 17 | - AliyunFCFullAccess 18 | 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | 22 | Parameters: 23 | type: object 24 | additionalProperties: false # 不允许增加其他属性 25 | required: # 必填项 26 | - region 27 | - functionName 28 | - runtime 29 | properties: 30 | region: 31 | title: 地域 32 | type: string 33 | default: cn-huhehaote 34 | description: 创建应用所在的地区 35 | enum: 36 | - cn-beijing 37 | - cn-hangzhou 38 | - cn-shanghai 39 | - cn-qingdao 40 | - cn-zhangjiakou 41 | - cn-huhehaote 42 | - cn-shenzhen 43 | - cn-chengdu 44 | - cn-hongkong 45 | - ap-southeast-1 46 | - ap-southeast-2 47 | - ap-southeast-3 48 | - ap-southeast-5 49 | - ap-northeast-1 50 | - eu-central-1 51 | - eu-west-1 52 | - us-west-1 53 | - us-east-1 54 | - ap-south-1 55 | functionName: 56 | title: 函数名称 57 | type: string 58 | default: start-dotnetcore-${default-suffix} 59 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 60 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 61 | runtime: 62 | title: dotnetcore 运行时 63 | type: string 64 | default: dotnetcore3.1 65 | description: 创建应用所在的地区 66 | enum: 67 | - dotnetcore3.1 68 | -------------------------------------------------------------------------------- /fc-dotnetcore/simple-http/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-dotnetcore/simple-http/src/HelloWorldApp/HelloWorldApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.1 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /fc-dotnetcore/simple-http/src/HelloWorldApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Text.Json; 5 | using Aliyun.Serverless.Core; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace Example 9 | { 10 | public class Hello 11 | { 12 | public class HTTPTriggerEvent 13 | { 14 | public string Version { get; set; } 15 | public string RawPath { get; set; } 16 | public string Body { get; set; } 17 | public bool IsBase64Encoded { get; set; } 18 | public RequestContext RequestContext { get; set; } 19 | public Dictionary Headers { get; set; } 20 | public Dictionary QueryParameters { get; set; } 21 | 22 | public override string ToString() 23 | { 24 | return JsonSerializer.Serialize(this); 25 | } 26 | } 27 | 28 | public class RequestContext 29 | { 30 | public string AccountId { get; set; } 31 | public string DomainName { get; set; } 32 | public string DomainPrefix { get; set; } 33 | public string RequestId { get; set; } 34 | public string Time { get; set; } 35 | public string TimeEpoch { get; set; } 36 | public Dictionary Http { get; set; } 37 | } 38 | 39 | public class HTTPTriggerResponse 40 | { 41 | public int StatusCode { get; set; } 42 | public Dictionary Headers { get; set; } 43 | public bool IsBase64Encoded { get; set; } 44 | public string Body { get; set; } 45 | } 46 | 47 | public HTTPTriggerResponse PocoHandler(HTTPTriggerEvent input, IFcContext context) 48 | { 49 | context.Logger.LogInformation("receive event: {0}", input.ToString()); 50 | string requestBody = input.Body; 51 | if (input.IsBase64Encoded) 52 | { 53 | byte[] decodedBytes = Convert.FromBase64String(input.Body); 54 | requestBody = Encoding.UTF8.GetString(decodedBytes); 55 | } 56 | return new HTTPTriggerResponse 57 | { 58 | StatusCode = 200, 59 | IsBase64Encoded = false, 60 | Body = requestBody 61 | }; 62 | } 63 | static void Main(string[] args){} 64 | } 65 | } -------------------------------------------------------------------------------- /fc-dotnetcore/simple-http/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - run: dotnet publish -c Release -o ./target 19 | path: ./HelloWorldApp 20 | props: 21 | region: ${vars.region} 22 | functionName: "{{ functionName }}" 23 | description: "hello world by serverless devs" 24 | runtime: "{{ runtime }}" 25 | code: ./HelloWorldApp/target/ 26 | handler: HelloWorldApp::Example.Hello::PocoHandler 27 | memorySize: 128 28 | timeout: 10 29 | triggers: 30 | - triggerName: httpTrigger # 触发器名称 31 | triggerType: http # 触发器类型 32 | description: "xxxx" 33 | qualifier: LATEST # 触发服务的版本 34 | triggerConfig: 35 | authType: anonymous # 鉴权类型,可选值:anonymous、function 36 | disableURLInternet: false # 是否禁用公网访问 URL 37 | methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 38 | - GET 39 | - POST 40 | -------------------------------------------------------------------------------- /fc-dotnetcore/simple-http/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-golang/hello-world/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-golang/hello-world/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-golang 5 | Version: 0.0.9 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Golang 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-huhehaote 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-beijing 38 | - cn-hangzhou 39 | - cn-shanghai 40 | - cn-qingdao 41 | - cn-zhangjiakou 42 | - cn-huhehaote 43 | - cn-shenzhen 44 | - cn-chengdu 45 | - cn-hongkong 46 | - ap-southeast-1 47 | - ap-southeast-2 48 | - ap-southeast-3 49 | - ap-southeast-5 50 | - ap-northeast-1 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-golang-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: golang 运行时 64 | type: string 65 | default: go1 66 | description: 创建应用所在的地区 67 | enum: 68 | - go1 69 | -------------------------------------------------------------------------------- /fc-golang/hello-world/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-golang/hello-world/src/code/go.mod: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | require github.com/aliyun/fc-runtime-go-sdk v0.2.7 4 | -------------------------------------------------------------------------------- /fc-golang/hello-world/src/code/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/aliyun/fc-runtime-go-sdk/fc" 7 | ) 8 | 9 | func main() { 10 | fc.Start(HandleRequest) 11 | } 12 | 13 | func HandleRequest(event []byte) (string, error) { 14 | fmt.Printf("event: %s\n", string(event)) 15 | fmt.Println("hello world! 你好,世界!") 16 | return "hello world! 你好,世界!", nil 17 | } 18 | -------------------------------------------------------------------------------- /fc-golang/hello-world/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-golang 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个 Golang 的 Hello World 函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-golang/hello-world/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-golang) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-golang) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-golang -d start-fc3-golang` 65 | - 进入项目,并进行项目部署:`cd start-fc3-golang && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-golang/hello-world/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - run: GO111MODULE=on go mod tidy 19 | path: ./code 20 | - run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go 21 | path: ./code 22 | props: 23 | region: ${vars.region} 24 | functionName: "{{ functionName }}" 25 | description: 'hello world by serverless devs' 26 | runtime: "{{ runtime }}" 27 | code: ./code/target 28 | handler: main 29 | memorySize: 128 30 | timeout: 10 31 | # triggers: 32 | # - triggerName: httpTrigger # 触发器名称 33 | # triggerType: http # 触发器类型 34 | # description: 'xxxx' 35 | # qualifier: LATEST # 触发服务的版本 36 | # triggerConfig: 37 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 38 | # disableURLInternet: false # 是否禁用公网访问 URL 39 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 40 | # - GET 41 | # - POST -------------------------------------------------------------------------------- /fc-golang/hello-world/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-golang/simple-http/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-golang/simple-http/publish.yaml: -------------------------------------------------------------------------------- 1 | Edition: 3.0.0 2 | Type: Project 3 | Name: start-fc3-golang-http 4 | Version: 0.0.6 5 | Provider: 6 | - 阿里云 7 | Description: 快速部署一个具有 http 触发器的 Golang 函数到阿里云函数计算。 8 | HomePage: https://github.com/devsapp/start-fc 9 | Tags: 10 | - 函数计算 11 | - 你好世界 12 | - 新手入门 13 | Category: 新手入门 14 | Service: 15 | 函数计算: 16 | Authorities: 17 | - AliyunFCFullAccess 18 | 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | 22 | Parameters: 23 | type: object 24 | additionalProperties: false # 不允许增加其他属性 25 | required: # 必填项 26 | - region 27 | - functionName 28 | - runtime 29 | properties: 30 | region: 31 | title: 地域 32 | type: string 33 | default: cn-huhehaote 34 | description: 创建应用所在的地区 35 | enum: 36 | - cn-beijing 37 | - cn-hangzhou 38 | - cn-shanghai 39 | - cn-qingdao 40 | - cn-zhangjiakou 41 | - cn-huhehaote 42 | - cn-shenzhen 43 | - cn-chengdu 44 | - cn-hongkong 45 | - ap-southeast-1 46 | - ap-southeast-2 47 | - ap-southeast-3 48 | - ap-southeast-5 49 | - ap-northeast-1 50 | - eu-central-1 51 | - eu-west-1 52 | - us-west-1 53 | - us-east-1 54 | - ap-south-1 55 | functionName: 56 | title: 函数名称 57 | type: string 58 | default: start-golang-${default-suffix} 59 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 60 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 61 | runtime: 62 | title: golang 运行时 63 | type: string 64 | default: go1 65 | description: 创建应用所在的地区 66 | enum: 67 | - go1 68 | -------------------------------------------------------------------------------- /fc-golang/simple-http/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-golang/simple-http/src/code/go.mod: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | require github.com/aliyun/fc-runtime-go-sdk v0.2.7 4 | -------------------------------------------------------------------------------- /fc-golang/simple-http/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-golang-http 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个具有 http 触发器的 Golang 函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-golang/simple-http/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-golang-http) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-golang-http) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-golang-http -d start-fc3-golang-http` 65 | - 进入项目,并进行项目部署:`cd start-fc3-golang-http && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-golang/simple-http/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - run: GO111MODULE=on go mod tidy 19 | path: ./code 20 | - run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o target/main main.go 21 | path: ./code 22 | props: 23 | region: ${vars.region} 24 | functionName: "{{ functionName }}" 25 | description: "hello world by serverless devs" 26 | runtime: "{{ runtime }}" 27 | code: ./code/target 28 | handler: main 29 | memorySize: 128 30 | timeout: 10 31 | triggers: 32 | - triggerName: httpTrigger # 触发器名称 33 | triggerType: http # 触发器类型 34 | description: "xxxx" 35 | qualifier: LATEST # 触发服务的版本 36 | triggerConfig: 37 | authType: anonymous # 鉴权类型,可选值:anonymous、function 38 | disableURLInternet: false # 是否禁用公网访问 URL 39 | methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 40 | - GET 41 | - POST 42 | -------------------------------------------------------------------------------- /fc-golang/simple-http/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-java/hello-world/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-java/hello-world/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-java 5 | Version: 0.0.10 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Java 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-huhehaote 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-beijing 38 | - cn-hangzhou 39 | - cn-shanghai 40 | - cn-qingdao 41 | - cn-zhangjiakou 42 | - cn-huhehaote 43 | - cn-shenzhen 44 | - cn-chengdu 45 | - cn-hongkong 46 | - ap-southeast-1 47 | - ap-southeast-2 48 | - ap-southeast-3 49 | - ap-southeast-5 50 | - ap-northeast-1 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-java-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: java 运行时 64 | type: string 65 | default: java11 66 | description: 创建应用所在的地区 67 | enum: 68 | - java11 69 | - java8 70 | -------------------------------------------------------------------------------- /fc-java/hello-world/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-java/hello-world/src/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | example 5 | HelloFCJava 6 | jar 7 | 1.0-SNAPSHOT 8 | HelloFCJava 9 | 10 | 11 | 12 | junit 13 | junit 14 | 3.8.1 15 | test 16 | 17 | 18 | com.aliyun.fc.runtime 19 | fc-java-core 20 | 1.4.1 21 | 22 | 23 | 24 | 25 | 26 | 27 | maven-assembly-plugin 28 | 29 | 30 | jar-with-dependencies 31 | 32 | 33 | 34 | 35 | make-my-jar-with-dependencies 36 | package 37 | 38 | single 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 52 | 53 | -------------------------------------------------------------------------------- /fc-java/hello-world/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-java 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个 Java 的 Hello World 函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-java/hello-world/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-java) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-java) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-java -d start-fc3-java` 65 | - 进入项目,并进行项目部署:`cd start-fc3-java && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-java/hello-world/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: 18 | - run: mvn package -DskipTests 19 | path: ./ 20 | props: 21 | region: ${vars.region} 22 | functionName: "{{ functionName }}" 23 | description: 'hello world by serverless devs' 24 | runtime: "{{ runtime }}" 25 | code: ./target/HelloFCJava-1.0-SNAPSHOT-jar-with-dependencies.jar 26 | handler: example.App::handleRequest 27 | memorySize: 128 28 | timeout: 10 29 | # triggers: 30 | # - triggerName: httpTrigger # 触发器名称 31 | # triggerType: http # 触发器类型 32 | # description: 'xxxx' 33 | # qualifier: LATEST # 触发服务的版本 34 | # triggerConfig: 35 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 36 | # disableURLInternet: false # 是否禁用公网访问 URL 37 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 38 | # - GET 39 | # - POST 40 | -------------------------------------------------------------------------------- /fc-java/hello-world/src/src/main/java/example/App.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.OutputStream; 7 | 8 | import com.aliyun.fc.runtime.Context; 9 | import com.aliyun.fc.runtime.StreamRequestHandler; 10 | import com.aliyun.fc.runtime.FunctionInitializer; 11 | 12 | /** 13 | * Hello world! 14 | * 15 | */ 16 | public class App implements StreamRequestHandler, FunctionInitializer { 17 | 18 | public void initialize(Context context) throws IOException { 19 | // TODO 20 | } 21 | 22 | @Override 23 | public void handleRequest( 24 | InputStream inputStream, OutputStream outputStream, Context context) throws IOException { 25 | outputStream.write(new String("hello world " + this.convert(inputStream)).getBytes()); 26 | } 27 | 28 | public String convert(InputStream inputStream) throws IOException { 29 | ByteArrayOutputStream result = new ByteArrayOutputStream(); 30 | byte[] buffer = new byte[1024]; 31 | int length; 32 | while ((length = inputStream.read(buffer)) != -1) { 33 | result.write(buffer, 0, length); 34 | } 35 | return result.toString("UTF-8"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /fc-java/hello-world/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-java/simple-http/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-java/simple-http/publish.yaml: -------------------------------------------------------------------------------- 1 | Edition: 3.0.0 2 | Type: Project 3 | Name: start-fc3-java-http 4 | Version: 0.0.5 5 | Provider: 6 | - 阿里云 7 | Description: 快速部署一个具有 http 触发器的 Java 函数到阿里云函数计算。 8 | HomePage: https://github.com/devsapp/start-fc 9 | Tags: 10 | - 函数计算 11 | - 你好世界 12 | - 新手入门 13 | Category: 新手入门 14 | Service: 15 | 函数计算: 16 | Authorities: 17 | - AliyunFCFullAccess 18 | 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | 22 | Parameters: 23 | type: object 24 | additionalProperties: false # 不允许增加其他属性 25 | required: # 必填项 26 | - region 27 | - functionName 28 | - runtime 29 | properties: 30 | region: 31 | title: 地域 32 | type: string 33 | default: cn-huhehaote 34 | description: 创建应用所在的地区 35 | enum: 36 | - cn-beijing 37 | - cn-hangzhou 38 | - cn-shanghai 39 | - cn-qingdao 40 | - cn-zhangjiakou 41 | - cn-huhehaote 42 | - cn-shenzhen 43 | - cn-chengdu 44 | - cn-hongkong 45 | - ap-southeast-1 46 | - ap-southeast-2 47 | - ap-southeast-3 48 | - ap-southeast-5 49 | - ap-northeast-1 50 | - eu-central-1 51 | - eu-west-1 52 | - us-west-1 53 | - us-east-1 54 | - ap-south-1 55 | functionName: 56 | title: 函数名称 57 | type: string 58 | default: start-java-${default-suffix} 59 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 60 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 61 | runtime: 62 | title: java 运行时 63 | type: string 64 | default: java11 65 | description: 创建应用所在的地区 66 | enum: 67 | - java11 68 | - java8 69 | -------------------------------------------------------------------------------- /fc-java/simple-http/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-java/simple-http/src/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | example 5 | HelloFCJava 6 | jar 7 | 1.0-SNAPSHOT 8 | HelloFCJava 9 | 10 | 11 | 12 | junit 13 | junit 14 | 3.8.1 15 | test 16 | 17 | 18 | com.aliyun.fc.runtime 19 | fc-java-core 20 | 1.4.1 21 | 22 | 23 | com.fasterxml.jackson.core 24 | jackson-databind 25 | 2.16.1 26 | 27 | 28 | org.projectlombok 29 | lombok 30 | 1.18.30 31 | provided 32 | 33 | 34 | 35 | 36 | 37 | 38 | maven-assembly-plugin 39 | 40 | 41 | jar-with-dependencies 42 | 43 | 44 | 45 | 46 | make-my-jar-with-dependencies 47 | package 48 | 49 | single 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 1.8 59 | 1.8 60 | 61 | 62 | -------------------------------------------------------------------------------- /fc-java/simple-http/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-java-http 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个具有 http 触发器的 Java 函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-java/simple-http/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-java-http) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-java-http) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-java-http -d start-fc3-java-http` 65 | - 进入项目,并进行项目部署:`cd start-fc3-java-http && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-java/simple-http/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | actions: 17 | pre-${regex('deploy|local')}: # 在deploy之前运行 18 | - run: mvn package -DskipTests 19 | path: ./ 20 | props: 21 | region: ${vars.region} 22 | functionName: "{{ functionName }}" 23 | description: "hello world by serverless devs" 24 | runtime: "{{ runtime }}" 25 | code: ./target/HelloFCJava-1.0-SNAPSHOT-jar-with-dependencies.jar 26 | handler: example.App::handleRequest 27 | memorySize: 128 28 | timeout: 10 29 | triggers: 30 | - triggerName: httpTrigger # 触发器名称 31 | triggerType: http # 触发器类型 32 | description: "xxxx" 33 | qualifier: LATEST # 触发服务的版本 34 | triggerConfig: 35 | authType: anonymous # 鉴权类型,可选值:anonymous、function 36 | disableURLInternet: false # 是否禁用公网访问 URL 37 | methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 38 | - GET 39 | - POST 40 | -------------------------------------------------------------------------------- /fc-java/simple-http/src/src/main/java/example/App.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import java.nio.charset.StandardCharsets; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import com.aliyun.fc.runtime.Context; 8 | import com.aliyun.fc.runtime.PojoRequestHandler; 9 | 10 | /** 11 | * HTTP Trigger demo 12 | * 13 | */ 14 | public class App implements PojoRequestHandler { 15 | 16 | @Override 17 | public HTTPTriggerResponse handleRequest(HTTPTriggerEvent request, Context context) { 18 | context.getLogger().info("Receive HTTP Trigger request: " + request.toString()); 19 | String requestBody = request.getBody(); 20 | if (request.isIsBase64Encoded()) { 21 | requestBody = new String(java.util.Base64.getDecoder().decode(request.getBody()), StandardCharsets.UTF_8); 22 | } 23 | String message = "HTTP Trigger request body: " + requestBody; 24 | context.getLogger().info(message); 25 | Map headers = new HashMap<>(); 26 | headers.put("Content-Type", "text/plain"); 27 | return HTTPTriggerResponse.builder().withStatusCode(200).withHeaders(headers).withBody(request.getBody()) 28 | .withIsBase64Encoded(request.isIsBase64Encoded()).build(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /fc-java/simple-http/src/src/main/java/example/HTTPTriggerEvent.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | import com.fasterxml.jackson.annotation.JsonProperty; 8 | 9 | import java.util.Map; 10 | 11 | @Data 12 | @NoArgsConstructor 13 | @AllArgsConstructor 14 | @Builder(setterPrefix = "with") 15 | public class HTTPTriggerEvent { 16 | private String version; 17 | private String rawPath; 18 | private Map headers; 19 | private Map queryParameters; 20 | private RequestContext requestContext; 21 | 22 | @JsonProperty("isBase64Encoded") 23 | private boolean IsBase64Encoded; 24 | private String body; 25 | 26 | @Data 27 | @NoArgsConstructor 28 | @AllArgsConstructor 29 | @Builder(setterPrefix = "with") 30 | public static class RequestContext { 31 | private String accountId; 32 | private String domainName; 33 | private String domainPrefix; 34 | private HttpInfo http; 35 | private String requestId; 36 | private String time; 37 | private String timeEpoch; 38 | 39 | @Data 40 | @NoArgsConstructor 41 | @AllArgsConstructor 42 | @Builder(setterPrefix = "with") 43 | public static class HttpInfo { 44 | private String method; 45 | private String path; 46 | private String protocol; 47 | private String sourceIp; 48 | private String userAgent; 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /fc-java/simple-http/src/src/main/java/example/HTTPTriggerResponse.java: -------------------------------------------------------------------------------- 1 | package example; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | import java.util.Map; 9 | 10 | import com.fasterxml.jackson.annotation.JsonProperty; 11 | 12 | @Data 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | @Builder(setterPrefix = "with") 16 | public class HTTPTriggerResponse { 17 | private int statusCode; 18 | private Map headers; 19 | 20 | @JsonProperty("isBase64Encoded") 21 | private boolean IsBase64Encoded; 22 | private String body; 23 | } -------------------------------------------------------------------------------- /fc-java/simple-http/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-node/exec-command/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-node/exec-command/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-nodejs-exec 5 | Version: 0.0.4 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Node.JS 调用外部命令的函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | Parameters: 22 | type: object 23 | additionalProperties: false # 不允许增加其他属性 24 | required: # 必填项 25 | - region 26 | - functionName 27 | - runtime 28 | properties: 29 | region: 30 | title: 地域 31 | type: string 32 | default: cn-huhehaote 33 | description: 创建应用所在的地区 34 | enum: 35 | - cn-beijing 36 | - cn-hangzhou 37 | - cn-shanghai 38 | - cn-qingdao 39 | - cn-zhangjiakou 40 | - cn-huhehaote 41 | - cn-shenzhen 42 | - cn-chengdu 43 | - cn-hongkong 44 | - ap-southeast-1 45 | - ap-southeast-2 46 | - ap-southeast-3 47 | - ap-southeast-5 48 | - ap-southeast-7 49 | - ap-northeast-1 50 | - ap-northeast-2 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-nodejs-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: nodejs 运行时 64 | type: string 65 | default: nodejs14 66 | description: 创建应用所在的地区 67 | enum: 68 | - nodejs10 69 | - nodejs12 70 | - nodejs14 71 | - nodejs16 72 | -------------------------------------------------------------------------------- /fc-node/exec-command/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-node/exec-command/src/code/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var exec = require('child_process').exec; 4 | exports.handler = (event, context, callback) => { 5 | console.log('start to execute a command'); 6 | exec("ls -l", function (error, stdout, stderr) { 7 | callback(null, stdout); 8 | }); 9 | } -------------------------------------------------------------------------------- /fc-node/exec-command/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-nodejs-exec 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个 Node.JS 调用外部命令的函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-node/exec-command/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-nodejs-exec) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-nodejs-exec) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-nodejs-exec -d start-fc3-nodejs-exec` 65 | - 进入项目,并进行项目部署:`cd start-fc3-nodejs-exec && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-node/exec-command/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} 18 | functionName: "{{ functionName }}" 19 | description: 'hello world by serverless devs' 20 | runtime: "{{ runtime }}" 21 | code: ./code 22 | handler: index.handler 23 | memorySize: 128 24 | timeout: 30 25 | # triggers: 26 | # - triggerName: httpTrigger # 触发器名称 27 | # triggerType: http # 触发器类型 28 | # description: 'xxxx' 29 | # qualifier: LATEST # 触发服务的版本 30 | # triggerConfig: 31 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 32 | # disableURLInternet: false # 是否禁用公网访问 URL 33 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 34 | # - GET 35 | # - POST 36 | -------------------------------------------------------------------------------- /fc-node/exec-command/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-node/hello-world-es/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-node/hello-world-es/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-nodejs-es 5 | Version: 0.0.3 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Node.JS 的 Hello World 函数(ES Module)到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | Parameters: 22 | type: object 23 | additionalProperties: false # 不允许增加其他属性 24 | required: # 必填项 25 | - region 26 | - functionName 27 | - runtime 28 | properties: 29 | region: 30 | title: 地域 31 | type: string 32 | default: cn-huhehaote 33 | description: 创建应用所在的地区 34 | enum: 35 | - cn-beijing 36 | - cn-hangzhou 37 | - cn-shanghai 38 | - cn-qingdao 39 | - cn-zhangjiakou 40 | - cn-huhehaote 41 | - cn-shenzhen 42 | - cn-chengdu 43 | - cn-hongkong 44 | - ap-southeast-1 45 | - ap-southeast-2 46 | - ap-southeast-3 47 | - ap-southeast-5 48 | - ap-southeast-7 49 | - ap-northeast-1 50 | - ap-northeast-2 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-nodejs-es-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: nodejs 运行时 64 | type: string 65 | default: nodejs20 66 | description: 创建应用所在的地区 67 | enum: 68 | - nodejs18 69 | - nodejs20 70 | -------------------------------------------------------------------------------- /fc-node/hello-world-es/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-node/hello-world-es/src/code/index.mjs: -------------------------------------------------------------------------------- 1 | 2 | export const handler = async (event, context) => { 3 | console.log("receive event: \n" + event); 4 | return "Hello World!"; 5 | }; -------------------------------------------------------------------------------- /fc-node/hello-world-es/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-nodejs-es 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个 Node.JS 的 Hello World 函数 (ES Module) 到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-node/hello-world-es/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-nodejs-es) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-nodejs-es) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-nodejs-es -d start-fc3-nodejs-es` 65 | - 进入项目,并进行项目部署:`cd start-fc3-nodejs-es && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-node/hello-world-es/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} 18 | functionName: "{{ functionName }}" 19 | description: 'hello world by serverless devs' 20 | runtime: "{{ runtime }}" 21 | code: ./code 22 | handler: index.handler 23 | memorySize: 128 24 | timeout: 30 25 | # triggers: 26 | # - triggerName: httpTrigger # 触发器名称 27 | # triggerType: http # 触发器类型 28 | # description: 'xxxx' 29 | # qualifier: LATEST # 触发服务的版本 30 | # triggerConfig: 31 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 32 | # disableURLInternet: false # 是否禁用公网访问 URL 33 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 34 | # - GET 35 | # - POST 36 | -------------------------------------------------------------------------------- /fc-node/hello-world-es/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-node/hello-world/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-node/hello-world/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-nodejs 5 | Version: 0.0.11 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Node.JS 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | Parameters: 22 | type: object 23 | additionalProperties: false # 不允许增加其他属性 24 | required: # 必填项 25 | - region 26 | - functionName 27 | - runtime 28 | properties: 29 | region: 30 | title: 地域 31 | type: string 32 | default: cn-huhehaote 33 | description: 创建应用所在的地区 34 | enum: 35 | - cn-beijing 36 | - cn-hangzhou 37 | - cn-shanghai 38 | - cn-qingdao 39 | - cn-zhangjiakou 40 | - cn-huhehaote 41 | - cn-shenzhen 42 | - cn-chengdu 43 | - cn-hongkong 44 | - ap-southeast-1 45 | - ap-southeast-2 46 | - ap-southeast-3 47 | - ap-southeast-5 48 | - ap-southeast-7 49 | - ap-northeast-1 50 | - ap-northeast-2 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-nodejs-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: nodejs 运行时 64 | type: string 65 | default: nodejs14 66 | description: 创建应用所在的地区 67 | enum: 68 | - nodejs10 69 | - nodejs12 70 | - nodejs14 71 | - nodejs16 72 | -------------------------------------------------------------------------------- /fc-node/hello-world/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-node/hello-world/src/code/index.js: -------------------------------------------------------------------------------- 1 | 2 | exports.handler = function (event, context, callback) { 3 | callback(null, 'hello world'); 4 | }; 5 | 6 | /* 7 | exports.handler = async function (event, context, callback) { 8 | callback(null, 'hello world'); 9 | }; 10 | */ -------------------------------------------------------------------------------- /fc-node/hello-world/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-nodejs 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个 Node.JS 的 Hello World 函数(CommonJS Module)到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-node/hello-world/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-nodejs) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-nodejs) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-nodejs -d start-fc3-nodejs` 65 | - 进入项目,并进行项目部署:`cd start-fc3-nodejs && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-node/hello-world/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} 18 | functionName: "{{ functionName }}" 19 | description: 'hello world by serverless devs' 20 | runtime: "{{ runtime }}" 21 | code: ./code 22 | handler: index.handler 23 | memorySize: 128 24 | timeout: 30 25 | # triggers: 26 | # - triggerName: httpTrigger # 触发器名称 27 | # triggerType: http # 触发器类型 28 | # description: 'xxxx' 29 | # qualifier: LATEST # 触发服务的版本 30 | # triggerConfig: 31 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 32 | # disableURLInternet: false # 是否禁用公网访问 URL 33 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 34 | # - GET 35 | # - POST 36 | -------------------------------------------------------------------------------- /fc-node/hello-world/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-node/json-event/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-node/json-event/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-nodejs-json 5 | Version: 0.0.4 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Node.JS 的解析JSON格式参数的函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | Parameters: 22 | type: object 23 | additionalProperties: false # 不允许增加其他属性 24 | required: # 必填项 25 | - region 26 | - functionName 27 | - runtime 28 | properties: 29 | region: 30 | title: 地域 31 | type: string 32 | default: cn-huhehaote 33 | description: 创建应用所在的地区 34 | enum: 35 | - cn-beijing 36 | - cn-hangzhou 37 | - cn-shanghai 38 | - cn-qingdao 39 | - cn-zhangjiakou 40 | - cn-huhehaote 41 | - cn-shenzhen 42 | - cn-chengdu 43 | - cn-hongkong 44 | - ap-southeast-1 45 | - ap-southeast-2 46 | - ap-southeast-3 47 | - ap-southeast-5 48 | - ap-southeast-7 49 | - ap-northeast-1 50 | - ap-northeast-2 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-nodejs-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: nodejs 运行时 64 | type: string 65 | default: nodejs14 66 | description: 创建应用所在的地区 67 | enum: 68 | - nodejs10 69 | - nodejs12 70 | - nodejs14 71 | - nodejs16 72 | -------------------------------------------------------------------------------- /fc-node/json-event/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-node/json-event/src/code/index.js: -------------------------------------------------------------------------------- 1 | exports.handler = function (event, context, callback) { 2 | var eventObj = JSON.parse(event.toString()); 3 | callback(null, eventObj['key']); 4 | }; -------------------------------------------------------------------------------- /fc-node/json-event/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} 18 | functionName: "{{ functionName }}" 19 | description: 'hello world by serverless devs' 20 | runtime: "{{ runtime }}" 21 | code: ./code 22 | handler: index.handler 23 | memorySize: 128 24 | timeout: 30 25 | # triggers: 26 | # - triggerName: httpTrigger # 触发器名称 27 | # triggerType: http # 触发器类型 28 | # description: 'xxxx' 29 | # qualifier: LATEST # 触发服务的版本 30 | # triggerConfig: 31 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 32 | # disableURLInternet: false # 是否禁用公网访问 URL 33 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 34 | # - GET 35 | # - POST 36 | -------------------------------------------------------------------------------- /fc-node/json-event/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-node/oss-event/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-node/oss-event/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-nodejs-oss 5 | Version: 0.0.5 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Node.JS 通过临时密钥安全读写OSS的资源函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | Parameters: 22 | type: object 23 | additionalProperties: false # 不允许增加其他属性 24 | required: # 必填项 25 | - region 26 | - functionName 27 | - runtime 28 | - ossBucket 29 | properties: 30 | region: 31 | title: 地域 32 | type: string 33 | default: cn-huhehaote 34 | description: 创建应用所在的地区 35 | enum: 36 | - cn-beijing 37 | - cn-hangzhou 38 | - cn-shanghai 39 | - cn-qingdao 40 | - cn-zhangjiakou 41 | - cn-huhehaote 42 | - cn-shenzhen 43 | - cn-chengdu 44 | - cn-hongkong 45 | - ap-southeast-1 46 | - ap-southeast-2 47 | - ap-southeast-3 48 | - ap-southeast-5 49 | - ap-southeast-7 50 | - ap-northeast-1 51 | - ap-northeast-2 52 | - eu-central-1 53 | - eu-west-1 54 | - us-west-1 55 | - us-east-1 56 | - ap-south-1 57 | functionName: 58 | title: 函数名称 59 | type: string 60 | default: start-nodejs-${default-suffix} 61 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 62 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 63 | runtime: 64 | title: nodejs 运行时 65 | type: string 66 | default: nodejs14 67 | description: 创建应用所在的地区 68 | enum: 69 | - nodejs10 70 | - nodejs12 71 | - nodejs14 72 | - nodejs16 73 | ossBucket: 74 | title: 对象存储存储桶名 75 | type: string 76 | default: "" 77 | description: 对象存储存储桶名,和函数在同一个 region 78 | x-bucket: 79 | dependency: 80 | - region 81 | functionRole: 82 | title: 函数角色 83 | type: string 84 | default: "" 85 | description: "函数计算访问其他云服务时使用的角色,配置 AliyunOSSFullAccess 权限。如果您首次使用函数计算,可以访问 https://fcnext.console.aliyun.com 进行授权。详细文档参考 https://help.aliyun.com/document_detail/2513600.html" 86 | required: true 87 | x-role: 88 | name: fcossrole 89 | service: fc 90 | authorities: 91 | - AliyunOSSFullAccess 92 | 93 | -------------------------------------------------------------------------------- /fc-node/oss-event/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-node/oss-event/src/code/index.js: -------------------------------------------------------------------------------- 1 | var OSSClient = require('ali-oss'); 2 | 3 | exports.handler = function (event, context, callback) { 4 | console.log(event.toString()); 5 | 6 | var ossClient = new OSSClient({ 7 | accessKeyId: context.credentials.accessKeyId, 8 | accessKeySecret: context.credentials.accessKeySecret, 9 | stsToken: context.credentials.securityToken, 10 | region: `oss-${context.region}`, 11 | bucket: process.env.BUCKET_NAME, 12 | }); 13 | 14 | ossClient.put('myObj', Buffer.from('hello, fc', "utf-8")).then(function (res) { 15 | callback(null, 'put object'); 16 | }).catch(function (err) { 17 | callback(err); 18 | }); 19 | }; -------------------------------------------------------------------------------- /fc-node/oss-event/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-nodejs-oss 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个 Node.JS 通过临时密钥安全读写 OSS 的资源函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-node/oss-event/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-nodejs-oss) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-nodejs-oss) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-nodejs-oss -d start-fc3-nodejs-oss` 65 | - 进入项目,并进行项目部署:`cd start-fc3-nodejs-oss && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-node/oss-event/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} 18 | functionName: "{{ functionName }}" 19 | description: 'hello world by serverless devs' 20 | runtime: "{{ runtime }}" 21 | role: "{{ functionRole }}" 22 | code: ./code 23 | handler: index.handler 24 | memorySize: 128 25 | timeout: 30 26 | environmentVariables: 27 | BUCKET_NAME: "{{ ossBucket }}" 28 | # triggers: 29 | # - triggerName: httpTrigger # 触发器名称 30 | # triggerType: http # 触发器类型 31 | # description: 'xxxx' 32 | # qualifier: LATEST # 触发服务的版本 33 | # triggerConfig: 34 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 35 | # disableURLInternet: false # 是否禁用公网访问 URL 36 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 37 | # - GET 38 | # - POST 39 | -------------------------------------------------------------------------------- /fc-node/oss-event/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-node/simple-http/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-node/simple-http/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-nodejs-http 5 | Version: 0.0.4 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个具有 http 触发器的 Node.JS 的示例函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | Parameters: 22 | type: object 23 | additionalProperties: false # 不允许增加其他属性 24 | required: # 必填项 25 | - region 26 | - functionName 27 | - runtime 28 | properties: 29 | region: 30 | title: 地域 31 | type: string 32 | default: cn-huhehaote 33 | description: 创建应用所在的地区 34 | enum: 35 | - cn-beijing 36 | - cn-hangzhou 37 | - cn-shanghai 38 | - cn-qingdao 39 | - cn-zhangjiakou 40 | - cn-huhehaote 41 | - cn-shenzhen 42 | - cn-chengdu 43 | - cn-hongkong 44 | - ap-southeast-1 45 | - ap-southeast-2 46 | - ap-southeast-3 47 | - ap-southeast-5 48 | - ap-southeast-7 49 | - ap-northeast-1 50 | - ap-northeast-2 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-nodejs-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: nodejs 运行时 64 | type: string 65 | default: nodejs14 66 | description: 创建应用所在的地区 67 | enum: 68 | - nodejs10 69 | - nodejs12 70 | - nodejs14 71 | - nodejs16 72 | -------------------------------------------------------------------------------- /fc-node/simple-http/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-node/simple-http/src/code/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | exports.handler = (event, context, callback) => { 3 | const eventObj = JSON.parse(event); 4 | console.log(`receive event: ${JSON.stringify(eventObj)}`); 5 | 6 | let body = 'Hello World!'; 7 | // get http request body 8 | if ("body" in eventObj) { 9 | body = eventObj.body; 10 | if (eventObj.isBase64Encoded) { 11 | body = Buffer.from(body, 'base64').toString('utf-8'); 12 | } 13 | } 14 | console.log(`receive http body: ${body}`); 15 | 16 | callback(null, { 17 | 'statusCode': 200, 18 | 'body': body 19 | }); 20 | } -------------------------------------------------------------------------------- /fc-node/simple-http/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} 18 | functionName: "{{ functionName }}" 19 | description: 'hello world by serverless devs' 20 | runtime: "{{ runtime }}" 21 | code: ./code 22 | handler: index.handler 23 | memorySize: 128 24 | timeout: 30 25 | triggers: 26 | - triggerName: httpTrigger # 触发器名称 27 | triggerType: http # 触发器类型 28 | description: 'xxxx' 29 | qualifier: LATEST # 触发服务的版本 30 | triggerConfig: 31 | authType: anonymous # 鉴权类型,可选值:anonymous、function 32 | disableURLInternet: false # 是否禁用公网访问 URL 33 | methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 34 | - GET 35 | - POST 36 | -------------------------------------------------------------------------------- /fc-node/simple-http/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-node/start-mcp-server/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | 3 | } 4 | 5 | async function postInit(inputObj) { 6 | 7 | } 8 | 9 | module.exports = { 10 | postInit, 11 | preInit 12 | } 13 | -------------------------------------------------------------------------------- /fc-node/start-mcp-server/publish.yaml: -------------------------------------------------------------------------------- 1 | Edition: 3.0.0 2 | Type: Project 3 | Name: start-mcp-server-nodejs 4 | Version: dev 5 | Provider: 6 | - 阿里云 # 取值内容参考:https://api.devsapp.cn/v3/common/args.html 7 | Description: FC MCP SSE Server案例 8 | HomePage: https://www.serverless-devs.com 9 | Tags: #标签详情 10 | - MCP 11 | Category: AI工具 # 取值内容参考:https://api.devsapp.cn/v3/common/args.html 12 | Service: # 使用的服务 13 | 函数计算: # 取值内容参考:https://api.devsapp.cn/v3/common/args.html 14 | Authorities: #权限描述 15 | - AliyunFCFullAccess # 所需要的权限,例如AliyunFCFullAccess 16 | Organization: 阿里云函数计算(FC) # 所属组织 17 | Effective: Public # 是否公开,取值:Public,Private,Organization 18 | Parameters: 19 | type: object 20 | additionalProperties: false # 不允许增加其他属性 21 | required: # 必填项 22 | - region 23 | - functionName 24 | properties: 25 | region: 26 | title: 地域 27 | type: string 28 | default: cn-hangzhou 29 | description: 创建应用所在的地区 30 | required: true 31 | enum: 32 | - cn-beijing 33 | - cn-hangzhou 34 | - cn-shanghai 35 | - cn-shenzhen 36 | - ap-southeast-1 37 | functionName: 38 | title: 函数名 39 | type: string 40 | required: true 41 | default: mcp-fc-server-${default-suffix} 42 | description: 函数名称,只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-64 之间 43 | -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/.signore: -------------------------------------------------------------------------------- 1 | ./code/node_modules/ 2 | ./code/dist -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/build.yaml: -------------------------------------------------------------------------------- 1 | mcp_server: 2 | default: 3 | languages: 4 | - nodejs20 5 | cache: 6 | paths: 7 | - "~/.npm" 8 | steps: 9 | - run: npm install 10 | path: ./code 11 | - run: npm run build 12 | path: ./code -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/code/.fcignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | 93 | # Gatsby files 94 | .cache/ 95 | # Comment in the public line in if your project uses Gatsby and not Next.js 96 | # https://nextjs.org/blog/next-9-1#public-directory-support 97 | # public 98 | 99 | # vuepress build output 100 | .vuepress/dist 101 | 102 | # vuepress v2.x temp and cache directory 103 | .temp 104 | .cache 105 | 106 | # Docusaurus cache and generated files 107 | .docusaurus 108 | 109 | # Serverless directories 110 | .serverless/ 111 | 112 | # FuseBox cache 113 | .fusebox/ 114 | 115 | # DynamoDB Local files 116 | .dynamodb/ 117 | 118 | # TernJS port file 119 | .tern-port 120 | 121 | # Stores VSCode versions used for testing VSCode extensions 122 | .vscode-test 123 | 124 | # yarn v2 125 | .yarn/cache 126 | .yarn/unplugged 127 | .yarn/build-state.yml 128 | .yarn/install-state.gz 129 | .pnp.* 130 | -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/code/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Nuxt.js build / generate output 91 | .nuxt 92 | dist 93 | 94 | # Gatsby files 95 | .cache/ 96 | # Comment in the public line in if your project uses Gatsby and not Next.js 97 | # https://nextjs.org/blog/next-9-1#public-directory-support 98 | # public 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # vuepress v2.x temp and cache directory 104 | .temp 105 | .cache 106 | 107 | # Docusaurus cache and generated files 108 | .docusaurus 109 | 110 | # Serverless directories 111 | .serverless/ 112 | 113 | # FuseBox cache 114 | .fusebox/ 115 | 116 | # DynamoDB Local files 117 | .dynamodb/ 118 | 119 | # TernJS port file 120 | .tern-port 121 | 122 | # Stores VSCode versions used for testing VSCode extensions 123 | .vscode-test 124 | 125 | # yarn v2 126 | .yarn/cache 127 | .yarn/unplugged 128 | .yarn/build-state.yml 129 | .yarn/install-state.gz 130 | .pnp.* 131 | -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/code/README.md: -------------------------------------------------------------------------------- 1 | An example MCP SSE weather server -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/code/check_node_version.mjs: -------------------------------------------------------------------------------- 1 | // check-node-version.mjs 2 | import semver from 'semver'; 3 | import process from 'process'; 4 | 5 | const MIN_VERSION = '20.0.0'; 6 | 7 | try { 8 | const current = process.version; 9 | if (semver.lt(current, MIN_VERSION)) { 10 | console.error(`error:Need Node.js ${MIN_VERSION} or higher version (current version: ${current})`); 11 | process.exit(1); 12 | } 13 | console.log(`Node version check pass: ${current}`); 14 | } catch (error) { 15 | console.error('Node version check failure: ', error.message); 16 | process.exit(1); 17 | } 18 | -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weather-node", 3 | "version": "1.0.0", 4 | "main": "dist/index.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1", 7 | "build": "rm -rf dist && tsc && webpack --config webpack.config.js", 8 | "start": "npm run build && node dist/index.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "description": "", 14 | "dependencies": { 15 | "@modelcontextprotocol/sdk": "^1.7.0", 16 | "express": "^5.0.1", 17 | "zod": "^3.24.2" 18 | }, 19 | "devDependencies": { 20 | "@types/express": "^5.0.1", 21 | "@types/node": "^20.0.0", 22 | "nyc": "^15.0.0", 23 | "source-map-support": "^0.5.16", 24 | "ts-loader": "^9.5.2", 25 | "ts-node": "^8.6.2", 26 | "typescript": "^5.8.2", 27 | "webpack": "^5.98.0", 28 | "webpack-cli": "^6.0.1", 29 | "webpack-node-externals": "^3.0.0" 30 | }, 31 | "bin": { 32 | "weather": "./build/index.js" 33 | }, 34 | "files": [ 35 | "dist", 36 | "src" 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/code/src/index.ts: -------------------------------------------------------------------------------- 1 | import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; 2 | import { z } from "zod"; 3 | import express from "express"; 4 | import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js"; 5 | 6 | // Create server instance 7 | const server = new McpServer({ 8 | name: "my-mcp-server", 9 | version: "1.0.0", 10 | }); 11 | 12 | // Implement your tools here 13 | server.tool( 14 | "hello_world", 15 | "Return string 'hello world!'", 16 | { 17 | // Define input parameters using zod. example: 18 | // prefix: z.string().describe('prefix').optional(), 19 | }, 20 | async () => { 21 | return { 22 | content: [{ 23 | type: "text", 24 | text: 'hello world!', 25 | }] 26 | } 27 | }, 28 | ); 29 | 30 | const app = express(); 31 | 32 | let transport: SSEServerTransport | null = null; 33 | 34 | app.get("/sse", (req, res) => { 35 | console.log("SSE connection opened"); 36 | transport = new SSEServerTransport("/messages", res); 37 | server.connect(transport); 38 | return; 39 | }); 40 | 41 | app.post("/messages", (req, res) => { 42 | if (transport) { 43 | console.log("SSE message received"); 44 | transport.handlePostMessage(req, res); 45 | } 46 | return; 47 | }); 48 | 49 | app.listen(3000, () => { 50 | console.log('MCP Server running on port 3000'); 51 | }); -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/code/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "sourceMap": true, 7 | "outDir": "./dist", 8 | "esModuleInterop": true 9 | }, 10 | "include": [ 11 | "src/**/*" 12 | ] 13 | } -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/code/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | mode: 'production', 5 | target: 'node', 6 | entry: './src/index.ts', 7 | output: { 8 | filename: 'index.js', 9 | path: path.resolve(__dirname, 'dist') 10 | }, 11 | module: { 12 | rules: [{ 13 | test: /\.ts$/, 14 | use: 'ts-loader', 15 | exclude: /node_modules/ 16 | }] 17 | }, 18 | resolve: { 19 | extensions: ['.ts', '.js'], 20 | }, 21 | // 关键配置:将所有依赖打包进bundle 22 | externalsPresets: { node: true }, 23 | node: { 24 | __dirname: false, 25 | __filename: false 26 | }, 27 | optimization: { 28 | minimize: false // 保持代码可读性 29 | } 30 | }; -------------------------------------------------------------------------------- /fc-node/start-mcp-server/src/s.yaml: -------------------------------------------------------------------------------- 1 | edition: 3.0.0 2 | name: start-mcp-server-nodejs 3 | access: '{{access}}' 4 | vars: 5 | region: '{{region}}' 6 | functionName: '{{functionName}}' 7 | resources: 8 | mcp_server: 9 | component: fc3 10 | actions: 11 | pre-deploy: 12 | - run: export PATH=/usr/local/versions/node/v20.8.1/bin:$PATH || true || ver && npm install && node check_node_version.mjs && npm run build 13 | path: ./code 14 | props: 15 | region: ${vars.region} 16 | description: Serverless Devs Node MCP Server 17 | runtime: custom.debian10 18 | timeout: 60 19 | memorySize: 512 20 | logConfig: auto 21 | environmentVariables: 22 | PATH: >- 23 | /var/fc/lang/nodejs20/bin:/opt/nodejs20/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 24 | customRuntimeConfig: 25 | command: 26 | - node 27 | - ./dist/index.js 28 | port: 3000 29 | functionName: ${vars.functionName} 30 | code: ./code 31 | instanceConcurrency: 10 32 | triggers: 33 | - triggerName: httpTrigger 34 | triggerType: http 35 | triggerConfig: 36 | authType: anonymous 37 | methods: 38 | - GET 39 | - POST 40 | - PUT 41 | - DELETE 42 | - HEAD 43 | - OPTIONS 44 | -------------------------------------------------------------------------------- /fc-node/start-mcp-server/version.md: -------------------------------------------------------------------------------- 1 | - 初始化项目 2 | - 测试项目模板 -------------------------------------------------------------------------------- /fc-php/hello-world/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-php/hello-world/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-php 5 | Version: 0.0.8 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 PHP 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | Parameters: 22 | type: object 23 | additionalProperties: false # 不允许增加其他属性 24 | required: # 必填项 25 | - region 26 | - functionName 27 | - runtime 28 | properties: 29 | region: 30 | title: 地域 31 | type: string 32 | default: cn-huhehaote 33 | description: 创建应用所在的地区 34 | enum: 35 | - cn-beijing 36 | - cn-hangzhou 37 | - cn-shanghai 38 | - cn-qingdao 39 | - cn-zhangjiakou 40 | - cn-huhehaote 41 | - cn-shenzhen 42 | - cn-chengdu 43 | - cn-hongkong 44 | - ap-southeast-1 45 | - ap-southeast-2 46 | - ap-southeast-3 47 | - ap-southeast-5 48 | - ap-southeast-7 49 | - ap-northeast-1 50 | - ap-northeast-2 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-php-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: php 运行时 64 | type: string 65 | default: php7.2 66 | description: 创建应用所在的地区 67 | enum: 68 | - php7.2 69 | -------------------------------------------------------------------------------- /fc-php/hello-world/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-php/hello-world/src/code/index.php: -------------------------------------------------------------------------------- 1 | info('initializing'); 9 | } 10 | */ 11 | 12 | function handler($event, $context) { 13 | $logger = $GLOBALS['fcLogger']; 14 | $logger->info('hello world'); 15 | return 'hello world'; 16 | } -------------------------------------------------------------------------------- /fc-php/hello-world/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-php 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个 PHP 的 Hello World 函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-php/hello-world/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-php) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-php) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-php -d start-fc3-php` 65 | - 进入项目,并进行项目部署:`cd start-fc3-php && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-php/hello-world/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} 18 | functionName: "{{ functionName }}" 19 | description: 'hello world by serverless devs' 20 | runtime: "{{ runtime }}" 21 | code: ./code 22 | handler: index.handler 23 | memorySize: 128 24 | timeout: 30 25 | # triggers: 26 | # - triggerName: httpTrigger # 触发器名称 27 | # triggerType: http # 触发器类型 28 | # description: 'xxxx' 29 | # qualifier: LATEST # 触发服务的版本 30 | # triggerConfig: 31 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 32 | # disableURLInternet: false # 是否禁用公网访问 URL 33 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 34 | # - GET 35 | # - POST -------------------------------------------------------------------------------- /fc-php/hello-world/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-php/simple-http/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-php/simple-http/publish.yaml: -------------------------------------------------------------------------------- 1 | Edition: 3.0.0 2 | Type: Project 3 | Name: start-fc3-php-http 4 | Version: 0.0.4 5 | Provider: 6 | - 阿里云 7 | Description: 快速部署一个具有 http 触发器 PHP 函数到阿里云函数计算。 8 | HomePage: https://github.com/devsapp/start-fc 9 | Tags: 10 | - 函数计算 11 | - 你好世界 12 | - 新手入门 13 | Category: 新手入门 14 | Service: 15 | 函数计算: 16 | Authorities: 17 | - AliyunFCFullAccess 18 | Organization: 阿里云函数计算(FC) 19 | Effective: Public 20 | Parameters: 21 | type: object 22 | additionalProperties: false # 不允许增加其他属性 23 | required: # 必填项 24 | - region 25 | - functionName 26 | - runtime 27 | properties: 28 | region: 29 | title: 地域 30 | type: string 31 | default: cn-huhehaote 32 | description: 创建应用所在的地区 33 | enum: 34 | - cn-beijing 35 | - cn-hangzhou 36 | - cn-shanghai 37 | - cn-qingdao 38 | - cn-zhangjiakou 39 | - cn-huhehaote 40 | - cn-shenzhen 41 | - cn-chengdu 42 | - cn-hongkong 43 | - ap-southeast-1 44 | - ap-southeast-2 45 | - ap-southeast-3 46 | - ap-southeast-5 47 | - ap-southeast-7 48 | - ap-northeast-1 49 | - ap-northeast-2 50 | - eu-central-1 51 | - eu-west-1 52 | - us-west-1 53 | - us-east-1 54 | - ap-south-1 55 | functionName: 56 | title: 函数名称 57 | type: string 58 | default: start-php-${default-suffix} 59 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 60 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 61 | runtime: 62 | title: php 运行时 63 | type: string 64 | default: php7.2 65 | description: 创建应用所在的地区 66 | enum: 67 | - php7.2 68 | -------------------------------------------------------------------------------- /fc-php/simple-http/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-php/simple-http/src/code/index.php: -------------------------------------------------------------------------------- 1 | info('hello world'); 6 | $logger->info('receive event: ' . $event); 7 | 8 | try { 9 | $evt = json_decode($event, true); 10 | if (is_null($evt['body'])) { 11 | return "The request did not come from an HTTP Trigger, event: " . $event; 12 | } 13 | $body = $evt['body']; 14 | if ($evt['isBase64Encoded']) { 15 | $body = base64_decode($evt['body']); 16 | } 17 | return array( 18 | "statusCode" => 200, 19 | 'headers' => array("Content-Type" => "text/plain"), 20 | 'isBase64Encoded' => false, 21 | "body" => $body 22 | ); 23 | } catch (Exception $e) { 24 | $logger->error("Caught exception: " . $e->getMessage()); 25 | return "The request did not come from an HTTP Trigger, event: " . $event; 26 | } 27 | } -------------------------------------------------------------------------------- /fc-php/simple-http/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-php-http 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个具有 http 触发器 PHP 函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-php/simple-http/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-php-http) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-php-http) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-php-http -d start-fc3-php-http` 65 | - 进入项目,并进行项目部署:`cd start-fc3-php-http && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-php/simple-http/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} 18 | functionName: "{{ functionName }}" 19 | description: "hello world by serverless devs" 20 | runtime: "{{ runtime }}" 21 | code: ./code 22 | handler: index.handler 23 | memorySize: 128 24 | timeout: 30 25 | triggers: 26 | - triggerName: httpTrigger # 触发器名称 27 | triggerType: http # 触发器类型 28 | description: "xxxx" 29 | qualifier: LATEST # 触发服务的版本 30 | triggerConfig: 31 | authType: anonymous # 鉴权类型,可选值:anonymous、function 32 | disableURLInternet: false # 是否禁用公网访问 URL 33 | methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 34 | - GET 35 | - POST 36 | -------------------------------------------------------------------------------- /fc-php/simple-http/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-python/hello-world/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-python/hello-world/publish.yaml: -------------------------------------------------------------------------------- 1 | 2 | Edition: 3.0.0 3 | Type: Project 4 | Name: start-fc3-python 5 | Version: 0.0.9 6 | Provider: 7 | - 阿里云 8 | Description: 快速部署一个 Python 的 Hello World 函数到阿里云函数计算。 9 | HomePage: https://github.com/devsapp/start-fc 10 | Tags: 11 | - 函数计算 12 | - 你好世界 13 | - 新手入门 14 | Category: 新手入门 15 | Service: 16 | 函数计算: 17 | Authorities: 18 | - AliyunFCFullAccess 19 | 20 | Organization: 阿里云函数计算(FC) 21 | Effective: Public 22 | 23 | Parameters: 24 | type: object 25 | additionalProperties: false # 不允许增加其他属性 26 | required: # 必填项 27 | - region 28 | - functionName 29 | - runtime 30 | properties: 31 | region: 32 | title: 地域 33 | type: string 34 | default: cn-huhehaote 35 | description: 创建应用所在的地区 36 | enum: 37 | - cn-beijing 38 | - cn-hangzhou 39 | - cn-shanghai 40 | - cn-qingdao 41 | - cn-zhangjiakou 42 | - cn-huhehaote 43 | - cn-shenzhen 44 | - cn-chengdu 45 | - cn-hongkong 46 | - ap-southeast-1 47 | - ap-southeast-2 48 | - ap-southeast-3 49 | - ap-southeast-5 50 | - ap-northeast-1 51 | - eu-central-1 52 | - eu-west-1 53 | - us-west-1 54 | - us-east-1 55 | - ap-south-1 56 | functionName: 57 | title: 函数名称 58 | type: string 59 | default: start-python-${default-suffix} 60 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 61 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 62 | runtime: 63 | title: python 运行时 64 | type: string 65 | default: python3.9 66 | description: 创建应用所在的地区 67 | enum: 68 | - python3.9 69 | - python3.10 70 | - python3.6 71 | -------------------------------------------------------------------------------- /fc-python/hello-world/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-python/hello-world/src/code/index.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import logging 4 | 5 | 6 | def handler(event, context): 7 | logger = logging.getLogger() 8 | logger.info(event) 9 | return event 10 | -------------------------------------------------------------------------------- /fc-python/hello-world/src/readme.md: -------------------------------------------------------------------------------- 1 | > 注:当前项目为 Serverless Devs 应用,由于应用中会存在需要初始化才可运行的变量(例如应用部署地区、函数名等等),所以**不推荐**直接 Clone 本仓库到本地进行部署或直接复制 s.yaml 使用,**强烈推荐**通过 `s init ${模版名称}` 的方法或应用中心进行初始化,详情可参考[部署 & 体验](#部署--体验) 。 2 | 3 | # start-fc3-python 帮助文档 4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 | 快速部署一个 Python 的 Hello World 函数到阿里云函数计算。 20 | 21 | 22 | 23 | 24 | 25 | - [:smiley_cat: 代码](https://github.com/devsapp/start-fc/tree/main/fc-python/hello-world/src) 26 | 27 | 28 | 29 | 30 | 31 | 32 | ## 前期准备 33 | 34 | 使用该项目,您需要有开通以下服务并拥有对应权限: 35 | 36 | 37 | 38 | | 服务/业务 | 权限 | 39 | | --------- | ------------------ | 40 | | 函数计算 | AliyunFCFullAccess | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | ## 部署 & 体验 53 | 54 | 55 | 56 | - :fire: 通过 [Serverless 应用中心](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-python) , 57 | [![Deploy with Severless Devs](https://img.alicdn.com/imgextra/i1/O1CN01w5RFbX1v45s8TIXPz_!!6000000006118-55-tps-95-28.svg)](https://fcnext.console.aliyun.com/applications/create?template=start-fc3-python) 该应用。 58 | 59 | 60 | 61 | 62 | - 通过 [Serverless Devs Cli](https://www.serverless-devs.com/serverless-devs/install) 进行部署: 63 | - [安装 Serverless Devs Cli 开发者工具](https://www.serverless-devs.com/serverless-devs/install) ,并进行[授权信息配置](https://docs.serverless-devs.com/fc/config) ; 64 | - 初始化项目:`s init start-fc3-python -d start-fc3-python` 65 | - 进入项目,并进行项目部署:`cd start-fc3-python && s deploy -y` 66 | 67 | 68 | 69 | 70 | 71 | ## 开发者社区 72 | 73 | 您如果有关于错误的反馈或者未来的期待,您可以在 [Serverless Devs repo Issues](https://github.com/serverless-devs/serverless-devs/issues) 中进行反馈和交流。如果您想要加入我们的讨论组或者了解 FC 组件的最新动态,您可以通过以下渠道进行: 74 | 75 |

76 | 77 | | | | | 78 | | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | 79 | |

微信公众号:`serverless`
|
微信小助手:`xiaojiangwh`
|
钉钉交流群:`33947367`
| 80 | 81 |

82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /fc-python/hello-world/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} 18 | functionName: "{{ functionName }}" 19 | description: 'hello world by serverless devs' 20 | runtime: "{{ runtime }}" 21 | code: ./code 22 | handler: index.handler 23 | memorySize: 128 24 | timeout: 30 25 | # triggers: 26 | # - triggerName: httpTrigger # 触发器名称 27 | # triggerType: http # 触发器类型 28 | # description: 'xxxx' 29 | # qualifier: LATEST # 触发服务的版本 30 | # triggerConfig: 31 | # authType: anonymous # 鉴权类型,可选值:anonymous、function 32 | # disableURLInternet: false # 是否禁用公网访问 URL 33 | # methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 34 | # - GET 35 | # - POST 36 | -------------------------------------------------------------------------------- /fc-python/hello-world/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 -------------------------------------------------------------------------------- /fc-python/simple-http/hook/index.js: -------------------------------------------------------------------------------- 1 | async function preInit(inputObj) { 2 | console.log(` 3 | Serverless Devs Application Case 4 | 5 | Cloud services required: 6 | - FC : https://fc.console.aliyun.com/ 7 | 8 | Tips: 9 | - FC3 Component: https://docs.serverless-devs.com/user-guide/aliyun/#fc3`) 10 | 11 | } 12 | 13 | async function postInit(inputObj) { 14 | console.log(` 15 | * Before using, please check whether the actions command in Yaml file is available 16 | * Carefully reading the notes in s.yaml is helpful for the use of the tool 17 | * If need help in the use process, please apply to join the Dingtalk Group: 33947367 18 | `) 19 | } 20 | 21 | module.exports = { 22 | postInit, 23 | preInit 24 | } 25 | -------------------------------------------------------------------------------- /fc-python/simple-http/publish.yaml: -------------------------------------------------------------------------------- 1 | Edition: 3.0.0 2 | Type: Project 3 | Name: start-fc3-python-http 4 | Version: 0.0.4 5 | Provider: 6 | - 阿里云 7 | Description: 快速部署一个具有 http 触发器的 Python 函数到阿里云函数计算。 8 | HomePage: https://github.com/devsapp/start-fc 9 | Tags: 10 | - 函数计算 11 | - 你好世界 12 | - 新手入门 13 | Category: 新手入门 14 | Service: 15 | 函数计算: 16 | Authorities: 17 | - AliyunFCFullAccess 18 | 19 | Organization: 阿里云函数计算(FC) 20 | Effective: Public 21 | 22 | Parameters: 23 | type: object 24 | additionalProperties: false # 不允许增加其他属性 25 | required: # 必填项 26 | - region 27 | - functionName 28 | - runtime 29 | properties: 30 | region: 31 | title: 地域 32 | type: string 33 | default: cn-huhehaote 34 | description: 创建应用所在的地区 35 | enum: 36 | - cn-beijing 37 | - cn-hangzhou 38 | - cn-shanghai 39 | - cn-qingdao 40 | - cn-zhangjiakou 41 | - cn-huhehaote 42 | - cn-shenzhen 43 | - cn-chengdu 44 | - cn-hongkong 45 | - ap-southeast-1 46 | - ap-southeast-2 47 | - ap-southeast-3 48 | - ap-southeast-5 49 | - ap-northeast-1 50 | - eu-central-1 51 | - eu-west-1 52 | - us-west-1 53 | - us-east-1 54 | - ap-south-1 55 | functionName: 56 | title: 函数名称 57 | type: string 58 | default: start-python-${default-suffix} 59 | pattern: "^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$" 60 | description: 只能包含字母、数字、下划线和中划线。不能以数字、中划线开头。长度在 1-128 之间。 61 | runtime: 62 | title: python 运行时 63 | type: string 64 | default: python3.9 65 | description: 创建应用所在的地区 66 | enum: 67 | - python3.9 68 | - python3.10 69 | - python3.6 70 | -------------------------------------------------------------------------------- /fc-python/simple-http/readme.md: -------------------------------------------------------------------------------- 1 | src/readme.md -------------------------------------------------------------------------------- /fc-python/simple-http/src/code/index.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import logging 3 | import json 4 | import base64 5 | 6 | def handler(event, context): 7 | logger = logging.getLogger() 8 | logger.info("receive event: %s", event) 9 | 10 | try: 11 | event_json = json.loads(event) 12 | except: 13 | return "The request did not come from an HTTP Trigger because the event is not a json string, event: {}".format(event) 14 | 15 | if "body" not in event_json: 16 | return "The request did not come from an HTTP Trigger because the event does not include the 'body' field, event: {}".format(event) 17 | req_body = event_json['body'] 18 | if 'isBase64Encoded' in event_json and event_json['isBase64Encoded']: 19 | req_body = base64.b64decode(event_json['body']).decode("utf-8") 20 | 21 | return { 22 | 'statusCode': 200, 23 | 'headers': {'Content-Type': 'text/plain'}, 24 | 'isBase64Encoded': False, 25 | 'body': req_body 26 | } 27 | -------------------------------------------------------------------------------- /fc-python/simple-http/src/s.yaml: -------------------------------------------------------------------------------- 1 | # ------------------------------------ 2 | # 官方手册: https://manual.serverless-devs.com/user-guide/aliyun/#fc3 3 | # 常见小贴士: https://manual.serverless-devs.com/user-guide/tips/ 4 | # 有问题快来钉钉群问一下吧:33947367 5 | # ------------------------------------ 6 | edition: 3.0.0 7 | name: hello-world-app 8 | access: "{{ access }}" 9 | 10 | vars: # 全局变量 11 | region: "{{ region }}" 12 | 13 | resources: 14 | hello_world: 15 | component: fc3 16 | props: 17 | region: ${vars.region} # 关于变量的使用方法,可以参考:https://docs.serverless-devs.com/serverless-devs/yaml#%E5%8F%98%E9%87%8F%E8%B5%8B%E5%80%BC 18 | functionName: "{{ functionName }}" 19 | description: "hello world by serverless devs" 20 | runtime: "{{ runtime }}" 21 | code: ./code 22 | handler: index.handler 23 | memorySize: 128 24 | timeout: 30 25 | triggers: 26 | - triggerName: httpTrigger # 触发器名称 27 | triggerType: http # 触发器类型 28 | description: "xxxx" 29 | qualifier: LATEST # 触发服务的版本 30 | triggerConfig: 31 | authType: anonymous # 鉴权类型,可选值:anonymous、function 32 | disableURLInternet: false # 是否禁用公网访问 URL 33 | methods: # HTTP 触发器支持的访问方法,可选值:GET、POST、PUT、DELETE、HEAD 34 | - GET 35 | - POST -------------------------------------------------------------------------------- /fc-python/simple-http/version.md: -------------------------------------------------------------------------------- 1 | - 新版本支持 --------------------------------------------------------------------------------