This topic describes how to deploy an expressCart application to Function Compute. Function Compute provides a method different from traditional deployment methods. You can deploy a traditional expressCart application to Function Compute and use the application for production without performing operations such as purchasing a server. The deployed expressCart application can use the auto scaling, pay-as-you-go, and O&M-free features of Function Compute.

Prerequisites

The following operations are complete:

Background information

An expressCart application is a component based on expressCart, an open source shopping website. You can use this component to deploy your own e-commerce shopping website with high efficiency.

Procedure

  1. Run the following command in the specified directory to initialize a project:
    s init  start-expresscart
    Sample command output:
    Serverless Awesome: https://github.com/Serverless-Devs/package-awesome
    
     Specify your project name (init dir) start-expresscart// By default, the system sets the project name for you. You can modify the project name as required. 
     file decompression completed
     Specify the endpoint of the ApsaraDB for MongoDB (Serverless) instance: mongodb://[username:password@]host[:port]// Specify the endpoint of the ApsaraDB for MongoDB (Serverless) instance as required. 
    
     Thanks for using Serverless-Devs
     You could [cd /test/start-expresscart] and enjoy your serverless journey!
     If you need help for this example, you can use [s -h] after you enter folder.
     Document Star: https://github.com/Serverless-Devs/Serverless-Devs
  2. Run the following command to go to the project directory:
    cd start-expresscart
  3. Run the following command to deploy the project:
    s deploy
    Sample command output:
    [2021-09-29T16:33:04.081] [INFO ] [S-CLI] - Start ...
    [2021-09-29T16:33:04.095] [INFO ] [S-CLI] - Start the pre-action
    [2021-09-29T16:33:04.095] [INFO ] [S-CLI] - Action: npm i
    npm WARN EBADENGINE Unsupported engine {
    npm WARN EBADENGINE   package: 'express-cart@1.1.19',
    npm WARN EBADENGINE   required: { node: '10.16.0' },
    npm WARN EBADENGINE   current: { node: 'v14.17.4', npm: '7.22.0' }
    npm WARN EBADENGINE }
    
    up to date in 2s
    [2021-09-29T16:33:05.993] [INFO ] [S-CLI] - End the pre-action
    ./expresscart path
    Sending build context to Docker daemon  1.883MB
     ......
     ---> Running in 748152961ece
    Removing intermediate container 748152961ece
     ---> 4556acb235f7
    Step 17/17 : ENTRYPOINT ["npm", "start"]
     ---> Running in 03c34e906857
    Removing intermediate container 03c34e906857
     ---> 050e32da9f30
    Successfully built 050e32da9f30
    Successfully tagged expresscart:latest
    execute build pack successfuly
    Login Succeeded
    
    login acr successfuly
    docker tag successfuly
    The push refers to repository [registry.cn-hangzhou.aliyuncs.com/serverlessdevs188077086902****/expresscart]
    
    ......
    84c62e276f70: Layer already exists
    
    1b3c69acba41: Layer already exists
    
    055415e8286d: Layer already exists
    
    721384ec99e5: Layer already exists
    
    a8ff54d4d483: Pushed
    
    
    a3a0a84ce2fd: Pushed
    
    1632904390344: digest: sha256:6a6a07bbfcc99fbacded28385d45410d7649a8439808ceb28faa079727d16e0d size: 3247
    
    docker push execute successfuly
    expressCart:
      serviceName:  expresscart-test
      functionName: express-cart
      domain:       60657313-188077086902****.example.com

Result

After the project is deployed, you can view the temporary domain name generated by Function Compute in the execution output. The temporary domain name can be used to access the newly deployed application. For example, run the following command to access the application:

curl 60657313-188077086902****.example.com
Note The temporary domain name is used only for demonstration and development purposes. It is valid for a limited period of time. You must use a domain name that has obtained an Internet Content Provider (ICP) filing from Alibaba Cloud for production. For more information, see Configure a custom domain name.