All Products
Search
Document Center

Function Compute:Konfigurasikan lapisan publik resmi

Last Updated:Apr 01, 2026

Memasukkan semua dependensi ke dalam paket penyebaran setiap fungsi menghasilkan arsip berukuran besar dan upaya duplikasi lintas fungsi. Function Compute menyediakan lapisan publik resmi untuk runtime dan pustaka dependensi umum. Tambahkan lapisan publik ini untuk berbagi dependensi antar fungsi tanpa perlu membangun ulang setiap kali.

Lapisan publik

Tabel berikut mencantumkan lapisan publik yang tersedia berdasarkan kategori. Untuk daftar lengkapnya, lihat Lapisan publik. Jika Anda memerlukan lapisan yang tidak tercantum, hubungi kami.

Runtime kustom

Lapisan-lapisan ini menyediakan lingkungan runtime untuk runtime kustom seperti Python 3.10 dan Node.js 17. Beberapa lapisan juga mencakup pustaka dependensi umum—misalnya, Python310-Package-Collection mencakup paket Python yang sering digunakan.

Public layerCompatible runtimeDescriptionReferences
PHP81-Debian10Custom.Debian10PHP 8.1 Debian 10 runtime layerREADME.md
PHP80-Debian10Custom.Debian10PHP 8.0 Debian 10 runtime layerREADME.md
NginxCustom.Debian10Nginx Debian 10 runtime layerREADME.md
Python310Custom, Custom.Debian10Python 3.10.5 runtime layerREADME.md
Python310-Package-CollectionCustom.Debian10A collection of common dependency libraries for the Python 3.10 runtimeREADME.md
Python39Custom, Custom.Debian10Python 3.9.13 runtime layerREADME.md
Python39-Package-CollectionCustom, Custom.Debian10A collection of common dependency libraries for the Python 3.9 runtimeREADME.md
Python38Custom, Custom.Debian10Python 3.8.13 runtime layerREADME.md
Python38-Package-CollectionCustom, Custom.Debian10A collection of common dependency libraries for the Python 3.8.13 runtimeREADME.md
Python36CustomPython 3.6.15 runtime layerREADME.md
Python36-Package-CollectionCustomA collection of common dependency libraries for the Python 3.6.15 runtimeREADME.md
Dotnet6Custom, Custom.Debian10ASP.NET 6.0.5 runtime layerREADME.md
PHP72CustomPHP 7.2 runtime layerREADME.md
Java8Custom.Debian10Java 8 runtime layerREADME.md
Java11Custom, Custom.Debian10Java 11 runtime layerREADME.md
Java17Custom, Custom.Debian10Java 17 runtime layerREADME.md
Java21Custom.Debian10Java 21 runtime layerREADME.md
Nodejs20Custom.Debian10Node.js 20 runtime layerREADME.md
Nodejs18Custom.Debian10Node.js 18 runtime layerREADME.md
Nodejs17CustomNode.js 17 runtime layerREADME.md
Nodejs16Custom, Custom.Debian10Node.js 16 runtime layerREADME.md
Nodejs14CustomNode.js 14 runtime layerREADME.md
Nodejs12CustomNode.js 12 runtime layerREADME.md
Go1Custom.Debian10Go 1 runtime layerREADME.md
Go118CustomGo 1.x runtime layerREADME.md

Pustaka dependensi umum

Public layerCompatible runtimeDescriptionCore library versionReferences
Python310-OSS2Python 3.10, Custom.Debian10oss2: OSS SDK for Python-README.md
Python39-OSS2Python 3.9, Custom.Debian10oss2: OSS SDK for Python-README.md
Python310-TensorFlow2xPython 3.10, Custom.Debian10An open source machine learning framework (CPU edition)tensorflow==2.15.0.post1README.md
Python3x-PyMongo4xPython 3.10, Custom.Debian10An open source scientific computing libraryPyMongo==4.6.1README.md
Python3x-Pandas2xPython 3.9, Custom.Debian10An open source data analysis and processing tool based on NumPypandas==2.2.1README.md
Python310-PyTorch2xPython 3.10, Custom.Debian10An open source machine learning framework (CPU edition)torch==2.2.1+cpuREADME.md
Python39-Pandas1xPython 3.9, Custom, Custom.Debian10An open source data analysis and processing tool based on NumPypandas==1.4.3README.md
Python39-SciPy1xPython 3.9, Custom, Custom.Debian10An open source scientific computing libraryscipy==1.9.0, numpy==1.23.2README.md
Python36-SciPy1xPython 3.6, CustomAn open source scientific computing libraryscipy-1.5.4, numpy-1.19.5README.md
Python39-PyTorch1xPython 3.9, Custom, Custom.Debian10An open source machine learning framework (CPU edition)torch==1.12.1+cpu, torchaudio==0.12.1+cpu, torchvision==0.13.1+cpuREADME.md
Python36-PyTorch1xPython 3.6, CustomAn open source machine learning framework (CPU edition)torch==1.10.2+cpu, torchaudio==0.10.2+cpu, torchvision==0.11.3+cpuREADME.md
Python3-Flask2xPython 3.9, Python 3.10, Custom, Custom.Debian10A Python-based lightweight web frameworkflask-v2.2.2README.md
Nodejs-Puppeteer17xNode.js 16, Node.js 14, Custom, Custom.Debian10A Headless Chrome toolpuppeteer-v17.1.0README.md
Nodejs-Puppeteer10xNode.js 14, Node.js 12, Node.js 10, CustomA Headless Chrome toolpuppeteer-v10.2.0README.md
Nodejs-Puppeteer19xCustom.Debian10A Headless Chrome toolpuppeteer-v19.8.5README.md
Python310-Opencv4xPython 3.10, Custom.Debian10A cross-platform library for computer visionopencv_python-4.7.0.68README.md
Python38-PlaywrightCustom.Debian10A tool for web page automationplaywright==1.31.1README.md
Poppler22x-Pdf2imagePython 3.10A library for rendering PDF documentspdf2image-1.16.3, poppler-22.12.0README.md
SQLite3Python 3.9, Node.js 16, Node.js 14, Java 11, Java 8, CustomA lightweight in-process relational database3.41.1README.md
FFmpeg6xPython 3.10, Python 3.9, Node.js 16, Node.js 14, Java 11, Java 8, Custom, Custom.Debian10An open source toolkit for recording, converting, and streaming audio and video6.0README.md
ServerlessDevsPython 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.Debian10An open source serverless platform that provides a robust set of tools for developers2.1.14README.md

Web frameworks

Public layerCompatible runtimeCore library versionReferences
Python3-Flask2xPython 3.9, Python 3.10, Custom, Custom.Debian10flask-2.2.2README.md

Alibaba Cloud SDKs

Public layerCompatible runtimeDescriptionReferences
Python310-Aliyun-SDKPython 3.10, Custom.Debian10Common Alibaba Cloud SDKs for Python 3.10README.md
Python39-Aliyun-SDKPython 3.9, CustomCommon Alibaba Cloud SDKs for Python 3.9README.md
Python36-Aliyun-SDKPython 3.6, CustomCommon Alibaba Cloud SDKs for Python 3.6README.md
Nodejs-Aliyun-SDKNode.js 20, Node.js 18, Node.js 16, Node.js 14, Custom, Custom.Debian10Common Alibaba Cloud SDKs (Node.js 20, Node.js 18, Node.js 16, and Node.js 14)README.md
Aliyun-DataXPython 3.6, Python 3.9, Custom, Custom.Debian10Open source edition of Alibaba Cloud DataWorks Data IntegrationREADME.md

Cara kerja lapisan

Satu fungsi mendukung hingga lima lapisan secara total, termasuk lapisan kustom dan lapisan publik. Saat beberapa lapisan dikonfigurasi, Function Compute menggabungkan isinya ke dalam direktori /opt dalam urutan terbalik. Jika dua lapisan berisi file dengan nama yang sama, file dari lapisan yang dikonfigurasi pertama akan mengambil prioritas dibandingkan file pada lapisan berikutnya.

Tambahkan lapisan publik di konsol

Prasyarat

Sebelum memulai, pastikan Anda telah:

  • Membuat fungsi Function Compute. Untuk membuatnya, lihat Buat fungsi.

Tambahkan lapisan

  1. Masuk ke Konsol Function Compute. Di panel navigasi sebelah kiri, klik Functions.

  2. Di bilah navigasi atas, pilih wilayah. Pada halaman Functions, klik nama fungsi yang ingin Anda konfigurasi.

  3. Di halaman detail fungsi, klik tab Configurations.

  4. Di pohon navigasi sebelah kiri, klik Layers, lalu klik Modify.

  5. Di panel Layers, klik + Add Layer dan pilih Add Official Common Layer. Pilih lapisan dari daftar drop-down Official Common Layer dan versi dari daftar drop-down Layer Version, lalu klik Deploy.

Tambahkan lapisan publik menggunakan Serverless Devs

Prasyarat

Sebelum memulai, pastikan Anda telah:

Tambahkan lapisan

  1. Jalankan perintah berikut untuk menampilkan daftar lapisan publik resmi di suatu wilayah:

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

    Output-nya mencantumkan lapisan yang tersedia beserta ARN-nya. Salin ARN lapisan yang ingin Anda gunakan.

    -
      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

    Bidang utama dalam output:

    FieldDescription
    layerNameNama lapisan
    versionVersi lapisan
    arnARN versi lapisan, digunakan saat menyambungkan lapisan ke fungsi
    aclKontrol akses: 0 = privat, 1 = publik
    descriptionDeskripsi singkat tentang lapisan
    compatibleRuntimeRuntime yang didukung oleh lapisan ini
  2. Di direktori proyek Anda, buat file s.yaml dan tambahkan ARN lapisan ke bidang layers.

    edition: 3.0.0
    name: hello-world-app
    access: "default"
    
    vars: # The global variables
      region: "cn-hangzhou"
    
    resources:
      hello_world:
        component: fc3 # The component name.
        actions:       # The custom execution logic.
        props:
          region: ${vars.region}
          functionName: "emoji"
          description: 'this is a layer demo'
          runtime: "python3.9"
          code: ./code
          handler: index.handler
          memorySize: 512
          timeout: 60
          internetAccess: true
          layers:    # The ARNs of the layers attached to the function.
            - acs:fc:cn-hangzhou:official:layers/Python39-Aliyun-SDK/versions/3
  3. Buat direktori code di direktori proyek Anda dan letakkan kode fungsi Anda di dalamnya.

  4. Jalankan perintah berikut untuk menyebar fungsi dengan lapisan yang telah dikonfigurasi:

    s deploy

Langkah selanjutnya