All Products
Search
Document Center

Function Compute:Configure a public layer for a function

Last Updated:Aug 06, 2024

Function Compute provides commonly used public layers. You can use public layers for functions without the need to configure your own layers. This topic describes how to configure a public layer for a function.

Public layers supported by Function Compute

This section lists public layers that are supported by Function Compute. If you cannot find the layer that you want to use, contact us.

Note

The following section lists only some public layers. For more information about the public layers that Function Compute supports, see Public layers.

Custom runtimes

Layers for custom runtimes, such as Python 3.10 and Node.js 17, are included. In the table, collections of some dependency libraries are also included. For example, the public layer Python310-Package-Collection includes commonly used Python dependency libraries.

Public layer

Compatible runtime

Description

References

PHP81-Debian10

Custom.Debian10

PHP 8.1 Debian 10 runtime layer

README.md

PHP80-Debian10

Custom.Debian10

PHP 8.0 Debian 10 runtime layer

README.md

Nginx

Custom.Debian10

Nginx Debian 10 runtime layer

README.md

Python310

  • Custom

  • Custom.Debian10

Python 3.10.5 runtime layer

README.md

Python310-Package-Collection

  • Custom

  • Custom.Debian10

A collection of common dependency libraries for the Python 3.10 runtime

README.md

Python39

  • Custom

  • Custom.Debian10

Python 3.9.13 runtime layer

README.md

Python39-Package-Collection

  • Custom

  • Custom.Debian10

A collection of common dependency libraries for the Python 3.9 runtime

README.md

Python38

  • Custom

  • Custom.Debian10

Python 3.8.13 runtime layer

README.md

Python38-Package-Collection

  • Custom

  • Custom.Debian10

A collection of common dependency libraries for the Python 3.8.13 runtime

README.md

Python36

Custom

Python 3.6.15 runtime layer

README.md

Python36-Package-Collection

Custom

A collection of common dependency libraries for the Python 3.6.15 runtime

README.md

Dotnet6

  • Custom

  • Custom.Debian10

ASP.NET 6.0.5 runtime layer

README.md

PHP72

Custom

PHP 7.2 runtime layer

README.md

Java8

Custom.Debian10

Java 8 runtime layer

README.md

Java11

  • Custom

  • Custom.Debian10

Java 11 runtime layer

README.md

Java17

  • Custom

  • Custom.Debian10

Java 17 runtime layer

README.md

Java21

Custom.Debian10

Java 21 runtime layer

README.md

Nodejs20

Custom.Debian10

Node.js 20 runtime layer

README.md

Nodejs18

Custom.Debian10

Node.js 18 runtime layer

README.md

Nodejs17

Custom

Node.js 17 runtime layer

README.md

Nodejs16

  • Custom

  • Custom.Debian10

Node.js 16 runtime layer

README.md

Nodejs14

Custom

Node.js 14 runtime layer

README.md

Nodejs12

Custom

Node.js 12 runtime layer

README.md

Go1

Custom.Debian10

Go 1 runtime layer

README.md

Go118

Custom

Go 1.x runtime layer

README.md

Common dependency libraries

Public layer

Compatible runtime

Description

Core library version

References

Python310-OSS2

  • Python 3.10

  • Custom.Debian10

oss2: Alibaba Cloud Object Storage Service (OSS) SDK for Python

-

README.md

Python39-OSS2

  • Python 3.9

  • Custom.Debian10

oss2: OSS SDK for Python

-

README.md

Python310-TensorFlow2x

  • Python 3.10

  • Custom.Debian10

An open source machine learning framework (CPU edition)

tensorflow==2.15.0.post1

README.md

Python3x-PyMongo4x

  • Python 3.10

  • Custom.Debian10

An open source scientific computing library

PyMongo==4.6.1

README.md

Python3x-Pandas2x

  • Python 3.9

  • Custom

  • Custom.Debian10

An open source data analysis and processing tool based on NumPy

  • pandas==2.2.1

  • numpy==1.23.2

README.md

Python310-PyTorch2x

  • Python 3.10

  • Custom.Debian10

An open source machine learning framework (CPU edition)

  • torch==1.10.2+cpu

  • torchaudio==0.10.2+cpu

  • torchvision==0.11.3+cpu

README.md

Python39-Pandas1x

  • Python 3.9

  • Custom

  • Custom.Debian10

An open source data analysis and processing tool based on NumPy

  • pandas==1.4.3

  • numpy==1.23.2

README.md

Python39-SciPy1x

  • Python 3.9

  • Custom

An open source scientific computing library

  • scipy==1.9.0

  • numpy==1.23.2

README.md

Python36-SciPy1x

  • Python 3.6

  • Custom

An open source scientific computing library

  • scipy-1.5.4

  • numpy-1.19.5

README.md

Python39-PyTorch1x

  • Python 3.9

  • Custom

  • Custom.Debian10

An open source machine learning framework (CPU edition)

  • torch==1.12.1+cpu

  • torchaudio==0.12.1+cpu

  • torchvision==0.13.1+cpu

README.md

Python36-PyTorch1x

  • Python 3.6

  • Custom

An open source machine learning framework (CPU edition)

  • torch==1.10.2+cpu

  • torchaudio==0.10.2+cpu

  • torchvision==0.11.3+cpu

README.md

Python3-Flask2x

  • Python 3.9

  • Python 3.10

  • Custom

  • Custom.Debian10

A Python-based lightweight web framework

v2.2.2

README.md

Nodejs-Puppeteer17x

  • Node.js 16

  • Node.js 14

  • Custom

  • Custom.Debian10

A Headless Chrome tool

puppeteer-v17.1.0

README.md

Nodejs-Puppeteer10x

  • Node.js 14

  • Node.js 12

  • Node.js 10

  • Custom

A Headless Chrome tool

puppeteer-v10.2.0

README.md

Python310-Opencv4x

  • Python 3.10

  • Custom.Debian10

A cross-platform library for computer vision.

v4.7.0.68

README.md

SQLite3

  • Python 3.9

  • Node.js 16

  • Node.js 14

  • Java 11

  • Java 8

  • Custom

A lightweight and in-process relational database

3.41.1

README.md

FFmpeg6x

  • Python 3.10

  • Python 3.9

  • Node.js 16

  • Node.js 14

  • Java 11

  • Java 8

  • Custom

  • Custom.Debian10

An open source software project that consists of a suite of programs used to record audio and videos, convert audio and video formats, and stream audio and video files.

6.0

README.md

Nodejs-Puppeteer19x

Custom.Debian10

A Headless Chrome tool

puppeteer-v19.8.5

README.md

Python38-Playwright

Custom.Debian10

puppeteer-v19.8.5

1.31.1

README.md

Poppler22x-Pdf2image

Python 3.10

A library for rendering PDF documents

22.12.0

README.md

ServerlessDevs

  • Python 3.10

  • Python 3.9

  • Python 3

  • Node.js 16

  • Node.js 14

  • Java 11

  • Java 8

  • Go 1

  • .NetCore 3.1

  • PHP 7.2

  • Custom

  • Custom.Debian10

An open source serverless platform that provides a robust set of tools for developers

2.1.14

README.md

Web framework

Public layer

Compatible runtime

Core library version

References

Python3-Flask2x

  • Python 3.9

  • Custom

flask-2.2.2

README.md

Alibaba Cloud SDKs

Public layer

Compatible runtime

Description

References

Python310-Aliyun-SDK

  • Python 3.10

  • Custom.Debian10

Common Alibaba Cloud SDKs for Python 3.10

README.md

Aliyun-DataX

  • Python 2.7

  • Python 3

  • Python 3.6

  • Python 3.9

  • Custom

  • Custom.Debian10

Open source edition of Alibaba Cloud DataWorks Data Integration

README.md

Python39-Aliyun-SDK

  • Python 3.9

  • Custom

Common Alibaba Cloud SDKs for Python 3.9

README.md

Python36-Aliyun-SDK

  • Python 3.6

  • Custom

Common Alibaba Cloud SDKs for Python 3.6

README.md

Nodejs-Aliyun-SDK

  • Node.js 20

  • Node.js 18

  • Node.js 16

  • Node.js 14

  • Custom

  • Custom.Debian10

Common Alibaba Cloud SDKs (Node.js 20, Node.js 18, Node.js 16, and Node.js 14)

README.md

Configure public layers in the Function Compute console

Before you start

Create a function

Procedure

  1. Log on to the Function Compute console. In the left-side navigation pane, click Services & Functions.

  2. In the top navigation bar, select a region. On the Services page, click the desired service.

  3. On the Functions page, find the desired function and click Configure in the Actions column.

  4. In the Layers section, click + Add Layer and select Add Public Layer from the drop-down list.

  5. In the Public Layer drop-down list, view the description and license information about the layers and select a public layer. In the Layer Version drop-down list, select a layer version and click Deploy.

Note
  • A function can be configured with a maximum of five layers, including custom layers and public layers.
  • When multiple layers are configured for a function, the content of these layers is merged and stored in the /opt directory in reverse order. If layers contain files with the same name, the files in the first configured layer overwrites the files with the same names in the later configured layer.

Configure public layers by using Serverless Devs

Before you start

Procedure

  1. Run the following command to list custom layers in a specified region:

    s cli fc layer list --official --region cn-hangzhou

    In the custom layer list that is returned, obtain and record the new ARN (arnV2) of the desired layer. The following sample code provides an example:

    -
      layerName:         Aliyun-DataX
      arn:
      arnV2:             acs:fc:cn-hangzhou:official:layers/Aliyun-DataX/versions/1
      version:           1
      acl:               1
      description:       Aliyun DataX for python (datax_v202205)
      compatibleRuntime:
        - custom
        - python2.7
        - python3
        - python3.9
    -
      layerName:         Python36-SciPy1x
      arn:
      arnV2:             acs:fc:cn-hangzhou:official:layers/Python36-SciPy1x/versions/1
      version:           1
      acl:               1
      description:       SciPy Layer for python36(scipy-1.5.4,numpy-1.19.5)
      compatibleRuntime:
        - custom
        - python3
    The following content describes the code snippets in the sample code:
    • layerName: the name of the layer.
    • version: the version of the layer.
    • arn: the original ARN of the layer. The original ARN can be used only in custom layers.
    • arnV2: the new ARN of the layer. The new ARN can be used only in public layers.
    • acl: the permissions of the layer. The digit 0 specifies that the layer is private and the digit 1 specifies that the layer is public. By default, the public layers are public. The custom layers can be set to private or public.
    • description: the description of the layer.
    • compatibleRuntime: the list of compatible runtimes.
  2. Create the s.yaml file in any directory and enter the obtained new ARN of the layer.

    Example:

    edition: 1.0.0          # The YAML version, which complies with semantic versioning specification.
    name: fcDeployApp       # The name of the project.
    access: "default"  # The alias of the key.
    
    services:
      fc-deploy-test: # The name of the service.
        component: fc  # The name of the component.
        props: # The attribute value of the component.
          region: cn-hangzhou
          service:
            name: fctest
            description: 'test'
            internetAccess: true
          function:
            name: emoji # The name of the function.
            description: this is a layer demo
            runtime: python3.9
            codeUri: ./
            handler: index.handler
            memorySize: 128
            timeout: 6
            layers:    # The layers bound to the function. The values are layer ARNs.
              - acs:fc:cn-hangzhou:official:layers/Aliyun-DataX/versions/1
              - acs:fc:cn-hangzhou:official:layers/Python39-SciPy1x/versions/1
  3. Run the following command in the directory in which the s.yaml file is stored to deploy the function and configure layers for the function:

    s deploy

References