Function Compute provides built-in runtimes for popular programming languages such as Node.js, Python, PHP, Java, C#, and Go, allowing you to focus on coding your business logic without worrying about any additional configuration. However, in certain scenarios, you may need to use less common programming languages or specific versions of a language to fulfill your specific business requirements. In such cases, you can create a custom runtime to establish a tailored environment. For example, you can use programming languages like Rust, or specify a version of Node.js, like Node.js 16, in your custom runtime.
We recommend that you use web functions with a custom runtime. This combination allows you to quickly set up various popular web application frameworks, making it easier to build and deploy HTTP-based applications and services. You can customize the startup command and listening port for your custom runtime, and instance-level concurrency is also supported.
Container environments
The following table lists the container environments supported by custom runtimes.
Runtime | Identifier | Operating system | Architecture |
Custom runtime (Debian 12) (in public preview) | custom.debian12 | Debian 12 | x86_64 |
Custom runtime (Debian 11) | custom.debian11 | Debian 11 | x86_64 |
Custom runtime (Debian 10) | custom.debian10 | Debian 10 | x86_64 |
Custom runtime (Debian 9) | custom | Debian 9 | x86_64 |
Custom runtime (Debian 12) is supported in the following regions: China (Hangzhou), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), and China (Chengdu).
Functions created after 00:00:00 on December 1, 2021
User permissions: Functions must be executed by root users.
Directory permissions: Data can be written to any directory.
Code location in the container: /code.
Functions created before 00:00:00 on December 1, 2021
User permissions: Functions must be executed by non-root users.
Directory permissions: Data can only be written to the /tmp directory.
Code location in the container: /code.
Environment information
Built-in dependencies
The built-in dependencies of a custom runtime are the same as those of a built-in runtime. For more information, see the following topics:
When you create a web function with a custom runtime, the system automatically configures the corresponding public layer for the programming language you use. For example, a Flask layer is automatically configured when you create a web function in Python.
Custom runtime (Debian 12)
The following table shows the built-in programming language of custom runtime (Debian 12). You can write code for your custom runtime function directly in the following language without installing third-party interpreters or configuring layers.
In some programming languages, you need to configure environment variables. Refer to the following table for details.
Programming language | Installation directory | Version | Environment variable |
Python 3.11 | /usr/bin/python3 | 3.11.2 | No extra settings required |
Custom runtime (Debian 11)
The following table shows the built-in programming language of custom runtime (Debian 11). You can write code for your custom runtime function directly in the following language without installing third-party interpreters or configuring layers.
In some programming languages, you need to configure environment variables. Refer to the following table for details.
Programming language | Installation directory | Version | Environment variable |
Python 3.12 | /var/fc/lang/python3.12 | 3.12.4 | PATH=/var/fc/lang/python3.12/bin:$PATH |
Custom runtime (Debian 10)
The following table lists the built-in programming languages of custom runtime (Debian 10). You can write code for your custom runtime function directly in the following languages without installing third-party interpreters or configuring layers.
In some programming languages, you need to configure environment variables. Refer to the following table for details.
Programming language | Installation directory | Version | Environment variable |
Node.js 20 | /var/fc/lang/nodejs20 | v20.10.0 | PATH=/var/fc/lang/nodejs20/bin:$PATH |
Node.js 18 | /var/fc/lang/nodejs18 | v18.19.0 | PATH=/var/fc/lang/nodejs18/bin:$PATH |
Python 3.10 | /var/fc/lang/python3.10 | 3.10.9 | PATH=/var/fc/lang/python3.10/bin:$PATH |
Python 2.7 | Default installation directory | 2.7.16 | N/A |
Custom runtime (Debian 9)
The following items list the built-in programming languages of custom runtime (Debian 9). You can write code for your custom runtime function directly in the following languages without installing third-party interpreters or configuring layers.
Python 3.7.4 (default Python version)
Node.js 10.16.2
OpenJDK 1.8.0
Ruby 2.7
Nginx 1.10.3
PHP 7.4.12
Use a non-built-in programming language
We recommend that you use a public layer if you want to write function code in a non-built-in programming language. For more information, see Configure common layers in the Function Compute console.
If you want to create a custom runtime by using a non-built-in programming language, you must package the interpreter or runtime for that language with your code file and deploy the package to Function Compute. For example, to create a Node.js 16 runtime, you must download the required interpreter, package it with your code, and then deploy the package to Function Compute. Perform the following steps:
Download
Node.jsof a 64-bit Linux version to the code package directory.wget http://mirrors.nju.edu.cn/nodejs/v16.14.2/node-v16.14.2-linux-x64.tar.gz -O node-v16.14.2-linux-x64.tar.gz && tar -zxvf node-v16.14.2-linux-x64.tar.gz && rm -rf node-v16.14.2-linux-x64.tar.gzConfigure the startup command of
Node.jsin the custom runtime.customRuntimeConfig: command: - /code/node-v16.14.2-linux-x64/bin/node args: - 'server.js' # You can also configure the following environment variable for your function: PATH=/code/node-v16.14.2-linux-x64/bin:/usr/local/bin/apache-maven/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ruby/bin. # After the configuration is complete, you can use Node.js to start the HTTP server.
Install dependencies
For more information about how to install the dependencies of each programming language in a custom runtime, see the following topics:
You can also use layers of Function Compute to install dependencies. We recommend that you use a public layer or build a dependency layer online. For more information, see the following topics: