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 do not need to install Docker but only Funcraft. The easiest way to install Funcraft is to download the executable binary files.

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

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 application to Function Compute.

    Funcraft automatically begins to deploy the application.

    $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 application is deployed, you can check the logs to find the temporary domain name that Function Compute generated. You can use this temporary domain name to access the deployed application.

    Note The temporary domain name is used only for demonstration and development purposes. It is valid for a limited period of time. To use an application in a production environment, you must bind the application to a domain name that has obtained an Internet Content Provider (ICP) filing from Alibaba Cloud. For more information, see Bind a custom domain name.