You can use Node.js to write functions in a custom container of Function Compute. This topic describes how to deploy and invoke a Node.js 14 function. You can also modify the Node.js sample code as needed for custom development.


  1. Run the following command in the specified directory to initialize a project:
    s init start-fc-custom-container-event-nodejs14 -d start-cc-nodejs14
    Note -d specifies the name of the folder in which the sample project resides. You can customize the folder name as required.
  2. Run the following command to go to the project directory:
    cd start-cc-nodejs14
  3. Optional: Modify the sample code as needed for custom development.
  4. Modify the s.yaml file.
    Change the value of the image field in the s.yaml file to your image name.
  5. Run the following command to deploy the project:
    s deploy -y
    Sample command output:
    [2022-02-09 06:30:23] [INFO] [S-CLI] - Start the pre-action
      region:   cn-hangzhou
        name: hello-world-service
        name:       nodejs14-event-function
        runtime:    custom-container
        handler:    not-used
        memorySize: 256
        timeout:    60
  6. Run the following command to remotely invoke the function:
    s invoke -e '{"key":"val"}'
    Sample command output:
    ========= FC invoke Logs begin =========
    /invoke is called.
    FC Invoke Start RequestId: 80850c2f-7f6b-474c-b63a-a4b8fb69c175
    2022-02-09T06:32:01 80850c2f-7f6b-474c-b63a-a4b8fb69c175 [INFO] handling invoke
    FC Invoke End RequestId: 80850c2f-7f6b-474c-b63a-a4b8fb69c175
    Duration: 0.71 ms, Billed Duration: 1 ms, Memory Size: 256 MB, Max Memory Used: 0.52 MB
    ========= FC invoke Logs end =========
    FC Invoke Result:
    End of method: invoke