This topic describes how to deploy Express applications to Function Compute. Compared with traditional deployment methods, you can deploy traditional Express applications to remote sites for direct production with one click. In addition, you can also enjoy features such as auto scaling, pay-as-you-go, and maintenance-free.

Background information

Express is a simple and flexible Web application development framework based on the Node.js platform. It provides a series of powerful characteristics to help you create a variety of Web and mobile device applications.

Step 1: Prepare the environment

You only need to install Funcraft instead of installing Docker. The simplest method is to download the executable binary files.

  1. Install Funcraft on the local machine. For more information, see Install Funcraft.
  2. Run the fun --version command to check whether the installation is successful.

Step 2: Deploy an application

  1. Use the following command to create an Express project.
    npx express-generator

    For more information, see Express application generator, or you can follow the steps described officially to create a simple Hello world example. If an Express project exists, this step is skipped.

  2. Use the following command to enter the sample project you created or an existing project.
    cd <project-name>
  3. Use the following command to install local dependencies.
    npm install
  4. Run the command to run the project.
    • MacOS and Linux
      DEBUG=myapp:* npm start
    • Windows
      set DEBUG=myapp:* & npm start
  5. Run the fun deploy -y command to deploy the project to Function Compute.

    Funcraft automatically enters the deployment process.

    $fun deploy -y
    current folder is not a fun project.
    Generating /Users/txd123/Desktop/Express/bootstrap...
    Generating template.yml...
    Generate Fun project successfully!
    ========= Fun will use 'fun deploy' to deploy your application to Function Compute! =========
    using region: cn-qingdao
    using accountId: ***********3743
    using accessKeyId: ***********Ptgk
    using timeout: 60
    Collecting your services information, in order to caculate devlopment changes...
    Resources Changes(Beta version! Only FC resources changes will be displayed):
    ...  ...  ...  ...
                   trigger httpTrigger deploy success
           function Express deploy success
    service Express deploy success
    Detect 'DomainName:Auto' of custom domain 'Domain'
    Request a new temporary domain ...
    The assigned temporary domain is,expired at 2020-04-12 10:46:25, limited by 1000 per day.
    Waiting for custom domain Domain to be deployed...
    custom domain Domain deploy success

    After the deployment is successful, you can see the temporary domain name generated by Function Compute in the log. Through this temporary domain name, you can directly access the just deployed application.

    Note The temporary domain name is only used for demonstration and development and is only valid for a period. For production purposes, bind a domain name that has been filed with Alibaba Cloud.