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

Prerequisites

The following operations are complete:

Procedure

  1. Run the following command in the specified directory to initialize a project:
    s init devsapp/start-pyramid -d start-pyramid
    The -d parameter specifies the project name. In this example, the project name is start-pyramid.
    Note Skip this step if the item exists.
    Sample command output:
     Serverless Awesome: https://github.com/Serverless-Devs/package-awesome
    
     devsapp!start-pyramid@0.0.6.zip file decompression completed
     please select credential alias default
    
        ______                          _     _
        | ___ \                        (_)   | |
        | |_/ /   _ _ __ __ _ _ __ ___  _  __| |
        |  __/ | | | '__/ _` | '_ ` _ \| |/ _` |
        | |  | |_| | | | (_| | | | | | | | (_| |
        \_|   \__, |_|  \__,_|_| |_| |_|_|\__,_|
               __/ |
              |___/
    
    
        Welcome to the start-pyramid application
         This application requires to open these services:
             FC : https://fc.console.aliyun.com/
             ACR: https://cr.console.aliyun.com/
         This application can help you quickly deploy the Pyramid project:
             Full yaml configuration : https://github.com/devsapp/pyramid#%E5%AE%8C%E6%95%B4yaml
             Pyramid development docs: https://trypyramid.com/documentation.html
         This application homepage: https://github.com/devsapp/start-pyramid
    
    
     Thanks for using Serverless-Devs
     You could [cd /test/start-pyramid] 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-pyramid
  3. Run the following command to deploy the project:
    s deploy
    Sample command output:
    [2021-08-31T11:00:59.574] [INFO ] [S-CLI] - Start ...
    [2021-08-31T11:00:59.583] [INFO ] [S-CLI] - Start the pre-action
    [2021-08-31T11:00:59.583] [INFO ] [S-CLI] - Action: pip3 install -t . -r requirements.txt
    WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
    Collecting pyramid==2.0 (from -r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/38/05/c75c59a1d8a3e44d3cb7d9ef9969bd4ff6dc18d860519dd1ef0cd547139f/pyramid-2.0-py3-none-any.whl (246 KB)
        100% |████████████████████████████████| 256 KB 15.9 MB/s
    Collecting setuptools (from pyramid==2.0->-r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/bd/25/5bdf7f1adeebd4e3fa76b2e2f045ae53ee208e40a4231ad0f0c3007e4353/setuptools-57.4.0-py3-none-any.whl (819 KB)
        100% |████████████████████████████████| 819 KB 8.4 MB/s
    Collecting translationstring>=0.4 (from pyramid==2.0->-r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/3b/98/36187601a15e3d37e9bfcf0e0e1055532b39d044353b06861c3a519737a9/translationstring-1.4-py2.py3-none-any.whl
    Collecting plaster (from pyramid==2.0->-r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/61/29/3ac8a5d03b2d9e6b876385066676472ba4acf93677acfc7360b035503d49/plaster-1.0-py2.py3-none-any.whl
    Collecting zope.deprecation>=3.5.0 (from pyramid==2.0->-r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/f9/26/b935bbf9d27e898b87d80e7873a0200cebf239253d0afe7a59f82fe90fff/zope.deprecation-4.4.0-py2.py3-none-any.whl
    Collecting plaster-pastedeploy (from pyramid==2.0->-r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/11/c4/0470056ea324c7a420c22647be512dec1b5e32b1b6e77e27c61838d2811c/plaster_pastedeploy-0.7-py2.py3-none-any.whl
    Collecting venusian>=1.0 (from pyramid==2.0->-r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/43/92/3d522a710867168ee422a0ffbd712c425ece937aaeec4381497a59e24faf/venusian-3.0.0-py3-none-any.whl
    Collecting zope.interface>=3.8.0 (from pyramid==2.0->-r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/67/67/8178e511cd4f0a481082aac1c0e2d64c520a5ee92ea8ce42d8297a4fca7e/zope.interface-5.4.0-cp36-cp36m-manylinux1_x86_64.whl (251 KB)
        100% |████████████████████████████████| 256 KB 425 KB/s
    Collecting webob>=1.8.3 (from pyramid==2.0->-r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/62/9c/e94a9982e9f31fc35cf46cdc543a6c2c26cb7174635b5fd25b0bbc6a7bc0/WebOb-1.8.7-py2.py3-none-any.whl (114 KB)
        100% |████████████████████████████████| 122 KB 1.9 MB/s
    Collecting hupper>=1.5 (from pyramid==2.0->-r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/9a/cb/d30896ad0d288358bbae60576556df78422179fc08c630f863258a7800ea/hupper-1.10.3-py2.py3-none-any.whl
    Collecting PasteDeploy>=2.0 (from plaster-pastedeploy->pyramid==2.0->-r requirements.txt (line 1))
      Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/8f/0b/d47ea894587f3155f8c4520aa74d57c856189d0bbe27e831881d655a3386/PasteDeploy-2.1.1-py2.py3-none-any.whl
    Installing collected packages: setuptools, translationstring, plaster, zope.deprecation, PasteDeploy, plaster-pastedeploy, venusian, zope.interface, webob, hupper, pyramid
    Successfully installed PasteDeploy-2.1.1 hupper-1.10.3 plaster-1.0 plaster-pastedeploy-0.7 pyramid-2.0 setuptools-57.4.0 translationstring-1.4 venusian-3.0.0 webob-1.8.7 zope.deprecation-4.4.0 zope.interface-5.4.0
    Target directory /test/start-pyramid/src/zope already exists. Specify --upgrade to force replacement.
    [2021-08-31T11:01:04.322] [INFO ] [S-CLI] - End the pre-action
      devsapp!pyramid@0.0.6.zip file decompression completed
      Using web framework type: nas, If you want to deploy with container, you can [s cli fc-default set web-framework container] to switch.
    (node:14083) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
    (Use `node --trace-deprecation ...` to show where the warning was created)
      End of request
      Deployed.
      End of request
    [2021-08-31T11:01:28.838] [INFO ] [FC-DEPLOY] - Using region: cn-shenzhen
    [2021-08-31T11:01:28.840] [INFO ] [FC-DEPLOY] - Using access alias: default
    [2021-08-31T11:01:28.841] [INFO ] [FC-DEPLOY] - Using accessKeyID: 188077086902****
    [2021-08-31T11:01:28.841] [INFO ] [FC-DEPLOY] - Using accessKeySecret: KdcUEJLoGto****
      Using fc deploy type: sdk, If you want to deploy with pulumi, you can [s cli fc-default set deploy-type pulumi] to switch.
    [2021-08-31T11:01:29.465] [INFO ] [FC-DEPLOY] - Checking Service serverless-devs-pyramid exists
    [2021-08-31T11:01:29.726] [INFO ] [FC-DEPLOY] - Setting role: AliyunFCDefaultRole
    [2021-08-31T11:01:30.115] [INFO ] [RAM] - Checking Role AliyunFCDefaultRole exists
    [2021-08-31T11:01:30.291] [INFO ] [RAM] - Updating role: AliyunFCDefaultRole
    [2021-08-31T11:01:30.399] [INFO ] [RAM] - Checking Plicy AliyunFCDefaultRolePolicy exists
    [2021-08-31T11:01:30.627] [INFO ] [FC-DEPLOY] - Using vpcConfig: auto: fc will try to generate related vpc resources automatically
    [2021-08-31T11:01:31.411] [INFO ] [VPC] - Getting vpc: fc-deploy-component-generated-vpc-cn-shenzhen
    [2021-08-31T11:01:31.519] [INFO ] [VPC] - Getting vswitch: fc-deploy-component-generated-vswitch-cn-shenzhen
    [2021-08-31T11:01:31.644] [INFO ] [VPC] - Getting securityGroup: fc-deploy-component-generated-securityGroup-cn-shenzhen
    [2021-08-31T11:01:31.793] [INFO ] [FC-DEPLOY] - Generated vpcConfig:
    securityGroupId: sg-wz92ctigpi221smc****
    vSwitchId: vsw-wz9qnuult4q5g4f7n****
    vpcId: vpc-wz9x9bzs0wtvjgt6n****
    
    [2021-08-31T11:01:31.793] [INFO ] [FC-DEPLOY] - Using nasConfig: auto: fc will try to generate related nas file system automatically
    [2021-08-31T11:01:57.879] [INFO ] [FC-DEPLOY] - Generated nasConfig:
    groupId: 10003
    mountPoints:
      - fcDir: /mnt/auto
        nasDir: /serverless-devs-pyramid
        serverAddr: example.com
    userId: 10003
    
    [2021-08-31T11:01:57.881] [INFO ] [FC-DEPLOY] - Checking Function pyramid exists
    [2021-08-31T11:01:57.991] [WARN ] [FC-DEPLOY] - Image registry.cn-shenzhen.aliyuncs.com/web-framework/python3:0.0.1 dose not exist locally.
    Maybe you need to run 's build' first if it dose not exist remotely.
    [2021-08-31T11:01:57.994] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-pyramid exists
    [2021-08-31T11:01:58.089] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-pyramid exists
    [2021-08-31T11:01:58.173] [INFO ] [FC-DEPLOY] - Creating service: serverless-devs-pyramid
    [2021-08-31T11:01:58.174] [INFO ] [FC-DEPLOY] - Creating function: pyramid
    [2021-08-31T11:01:58.174] [INFO ] [FC-DEPLOY] - Creating triggers: ["serverless-devs-pyramid"]
      Make service serverless-devs-pyramid success.
      Make function serverless-devs-pyramid/pyramid success.
      Make trigger serverless-devs-pyramid/pyramid/serverless-devs-pyramid success.
    [2021-08-31T11:02:01.403] [INFO ] [FC-DEPLOY] - Checking Service serverless-devs-pyramid exists
    [2021-08-31T11:02:01.476] [INFO ] [FC-DEPLOY] - Checking Function pyramid exists
    [2021-08-31T11:02:01.602] [INFO ] [FC-DEPLOY] - Checking Trigger serverless-devs-pyramid exists
    [2021-08-31T11:02:01.777] [INFO ] [FC-DEPLOY] - Creating custom domain: pyramid.serverless-devs-pyramid.188077086902****.cn-shenzhen.fc.devsapp.net
    [2021-08-31T11:02:02.615] [INFO ] [FC-DOMAIN] - Creating custom domain: pyramid.serverless-devs-pyramid.188077086902****.cn-shenzhen.fc.devsapp.net
    
    There is auto config in the service: serverless-devs-pyramid
    [2021-08-31T11:02:03.348] [INFO ] [WEB-FRAMEWORK] - nas component get src is: ./src
    Packing ...
    Package complete.
      Start uploading file: /mnt/2bfb748534-tpm20-cn-shenzhen/serverless-devs-pyramid/pyramid/src.zip
      File uploaded successfully: /mnt/2bfb748534-tpm20-cn-shenzhen/serverless-devs-pyramid/pyramid/src.zip
      upload done
    [2021-08-31T11:02:44.846] [INFO ] [FC-NAS] - unzipping file
    [2021-08-31T11:02:47.997] [INFO ] [FC-NAS] - unzip done
      Try container acceleration
    framework-test:
      region: cn-shenzhen
      serviceName: serverless-devs-pyramid
      functionName: pyramid
      customDomains:
        - >-
          http://pyramid.serverless-devs-pyramid.188077086902****.cn-shenzhen.fc.devsapp.net

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 http://pyramid.serverless-devs-pyramid.188077086902****.cn-shenzhen.fc.devsapp.net
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.