Function Compute provides commonly used public layers. You can use the official public layers for functions without the need to configure your own layers. This topic describes how to configure an official public layer for a function.
Common layers in Function Compute
This section lists the official public layers that are supported by Function Compute. If you cannot find the layer that you want to use, contact us.
The following section lists only some commonly used public layers. For more information about the public layers that Function Compute supports, see Public layers.
Custom runtimes
The table in this section lists layers that are compatible with specific custom runtimes, such as Python 3.10 and Node.js 17. In the table, collections of some dependency libraries are 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 | |
PHP80-Debian10 | Custom.Debian10 | PHP 8.0 Debian 10 runtime layer | |
Nginx | Custom.Debian10 | Nginx Debian 10 runtime layer | |
Python310 |
| Python 3.10.5 runtime layer | |
Python310-Package-Collection |
| A collection of common dependency libraries for the Python 3.10 runtime | |
Python39 |
| Python 3.9.13 runtime layer | |
Python39-Package-Collection |
| A collection of common dependency libraries for the Python 3.9 runtime | |
Python38 |
| Python 3.8.13 runtime layer | |
Python38-Package-Collection |
| A collection of common dependency libraries for the Python 3.8.13 runtime | |
Python36 | Custom | Python 3.6.15 runtime layer | |
Python36-Package-Collection | Custom | A collection of common dependency libraries for the Python 3.6.15 runtime | |
Dotnet6 |
| ASP.NET 6.0.5 runtime layer | |
PHP72 | Custom | PHP 7.2 runtime layer | |
Java8 | Custom.Debian10 | Java 8 runtime layer | |
Java11 |
| Java 11 runtime layer | |
Java17 |
| Java 17 runtime layer | |
Java21 | Custom.Debian10 | Java 21 runtime layer | |
Nodejs20 | Custom.Debian10 | Node.js 20 runtime layer | |
Nodejs18 | Custom.Debian10 | Node.js 18 runtime layer | |
Nodejs17 | Custom | Node.js 17 runtime layer | |
Nodejs16 |
| Node.js 16 runtime layer | |
Nodejs14 | Custom | Node.js 14 runtime layer | |
Nodejs12 | Custom | Node.js 12 runtime layer | |
Go1 | Custom.Debian10 | Go 1 runtime layer | |
Go118 | Custom | Go 1.x runtime layer |
Common dependency libraries
Public layer | Compatible runtime | Description | Core library version | References |
Python310-OSS2 |
| oss2: OSS SDK for Python | - | |
Python39-OSS2 |
| oss2: OSS SDK for Python | - | |
Python310-TensorFlow2x |
| An open source machine learning framework (CPU edition) | tensorflow==2.15.0.post1 | |
Python3x-PyMongo4x |
| An open source scientific computing library | PyMongo==4.6.1 | |
Python3x-Pandas2x |
| An open source data analysis and processing tool based on NumPy |
| |
Python310-PyTorch2x |
| An open source machine learning framework (CPU edition) |
| |
Python39-Pandas1x |
| An open source data analysis and processing tool based on NumPy |
| |
Python39-SciPy1x |
| An open source scientific computing library |
| |
Python36-SciPy1x |
| An open source scientific computing library |
| |
Python39-PyTorch1x |
| An open source machine learning framework (CPU edition) |
| |
Python36-PyTorch1x |
| An open source machine learning framework (CPU edition) |
| |
Python3-Flask2x |
| A Python-based lightweight web framework | v2.2.2 | |
Nodejs-Puppeteer17x |
| A Headless Chrome tool | puppeteer-v17.1.0 | |
Nodejs-Puppeteer10x |
| A Headless Chrome tool | puppeteer-v10.2.0 | |
Python310-Opencv4x |
| A cross-platform library for computer vision | v4.7.0.68 | |
SQLite3 |
| A lightweight and in-process relational database | 3.41.1 | |
FFmpeg6x |
| An open source software project that consists of a set of programs used to record audio and videos, convert audio and video formats, and stream audio and video files | 6.0 | |
Nodejs-Puppeteer19x | Custom.Debian10 | A Headless Chrome tool | puppeteer-v19.8.5 | |
Python38-Playwright | Custom.Debian10 | puppeteer-v19.8.5 | 1.31.1 | |
Poppler22x-Pdf2image | Python 3.10 | A library for rendering PDF documents | 22.12.0 | |
ServerlessDevs |
| An open source serverless platform that provides a robust set of tools for developers | 2.1.14 |
Web framework
Public layer | Compatible runtime | Core library version | References |
Python3-Flask2x |
| flask-2.2.2 |
Alibaba Cloud SDKs
Public layer | Compatible runtime | Description | References |
Python310-Aliyun-SDK |
| Common Alibaba Cloud SDKs for Python 3.10 | |
Aliyun-DataX |
| Open source edition of Alibaba Cloud DataWorks Data Integration | |
Python39-Aliyun-SDK |
| Common Alibaba Cloud SDKs for Python 3.9 | |
Python36-Aliyun-SDK |
| Common Alibaba Cloud SDKs for Python 3.6 | |
Nodejs-Aliyun-SDK |
| Common Alibaba Cloud SDKs (Node.js 20, Node.js 18, Node.js 16, and Node.js 14) |
Configure common layers in the Function Compute console
Before you start
Procedure
Log on to the Function Compute console. In the left-side navigation pane, click Functions.
In the top navigation bar, select a region. On the Functions page, click the name of the function that you want to manage.
On the function details page, click the Configurations tab.
In the left-side navigation tree, click Layers. Click Modify. In the Layers panel, choose . Then, select a layer from the Official Common Layer drop-down list and its version from the Layer Version drop-down list and click Deploy.
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 to 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 a public layer by using Serverless Devs
Before you start
Procedure
Run the following command to find custom layers in the specified region:
s cli fc layer list --official --region cn-hangzhou
In the custom layer list that is returned, obtain and record the Alibaba Cloud Resource Name (ARN) of the desired layer.
- layerName: Python39-Aliyun-SDK arn: acs:fc:cn-hangzhou:official:layers/Python39-Aliyun-SDK/versions/3 version: 3 acl: 1 description: Python3.9 Aliyun SDK layer. compatibleRuntime: - custom - python3.9 - custom.debian10 - layerName: Python39-Package-Collection arn: acs:fc:cn-hangzhou:official:layers/Python39-Package-Collection/versions/3 version: 3 acl: 1 description: Python3.9 package collection layer. compatibleRuntime: - custom - custom.debian10
Description:
layerName: the name of the layer.
version: the version of the layer.
arn: the ARN of the layer.
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.
In the target directory, create a s.yaml file and enter the obtained layer arn information.
Example:
edition: 3.0.0 name: hello-world-app access: "default" vars: # The global variable. region: "cn-hangzhou" resources: hello_world: component: fc3 # The component name actions: # The custom execution logic. For more information about actions, visit https://docs.serverless-devs.com/serverless-devs/yaml#%E8%A1%8C%E4%B8%BA%E6%8F%8F%E8%BF%B0actions. props: region: ${vars.region} # For information about how to use variables, visit: https://docs.serverless-devs.com/serverless-devs/yaml#%E5%8F%98%E9%87%8F%E8%B5%8B%E5%80%BC. functionName: "emoji" description: 'this is a layer demo' runtime: "python3.9" code: ./code handler: index.handler memorySize: 512 timeout: 60 internetAccess: true layers: # The layers bound to the function. The values are the ARNs of the layers. - acs:fc:cn-hangzhou:official:layers/Python39-Aliyun-SDK/versions/3
Create a
code
hierarchy in the target directory, and then prepare the function code in thecode
.Run the following command in the target directory to deploy the function and configure layers for the function:
s deploy
More information
You can also use API operations and SDKs to manage and configure layers. For more information, see CreateFunction and UpdateFunction.
If the error "xxx is not supported by layer" is reported when you configure a layer for a function, fix the issue by referring to What do I do if "xxx is not supported by layer" is reported when I configure a layer for a function?