This topic describes how to use a custom runtime to write functions in aFunction Compute.
Background information
- Customize personalized languages, such as Rust.
- Use a runtime environment of the specified version for a programming language, such as Node.js 16.
Container environment
- Operating system: Debian 9
- Architecture: x86_64.
- User permissions:
- If functions are created at and after 00:00:00 December 1, 2021, the functions must be executed by the root user.
- If functions are created before 00:00:00 December 1, 2021, the functions must be executed by a non-root user.
- Directory permissions:
- If functions are created at and after 00:00:00 December 1, 2021, all the directories are writable.
- If functions are created before 00:00:00 December 1, 2021, only the /tmp directory is writable.
- Directory location of the code in the container: /code.
Environment Information
- Python 3.7.4
- Node.js 10.16.2
- OpenJDK 1.8.0
- Ruby 2.7
- PowerShell 7.1.0
- Nginx 1.10.3
- PHP 7.4.12
Among them, PHP 7.4.12 built-in extensions list as follows:
bcmath calendar Core ctype curl date dom exif FFI fileinfo filter ftp gd gettext hash iconv imagick imap intl json libxml mbstring mcrypt memcached mysqli mysqlnd openSSL pcntl pcre PDO pdo_mysql pdo_pgsql pdo_sqlite pgsql Phar posix protobuf readline redis Reflection session shmop SimpleXML soap sockets sodium SPL sqlite3 standard swoole sysvmsg sysvsem sysvshm tokenizer xml xmlreader xmlrpc xmlwriter xsl Zend OPcache zip zlib None
For more information about the built-in software of custom runtime, see Details.
Use non-built-in programming languages
If you plan to use a language to make a custom runtime, but the language is not a built-in language for the custom runtime, you need to package and deploy the language's parser or runtime and code files to the Function Compute to achieve your intended goals. For example, if the runtime environment is Node.js 16, you must download the interpreter of Node.js 16, compress the interpreter and your code file into a package, and then deploy the package in Function Compute. Perform the following steps:
- Download the Linux-x64 version of the
node
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.gz
- Set the
node
to use the custom runtime startup command.customRuntimeConfig: command: - /code/node-v16.14.2-linux-x64/bin/node args: - 'server.js' # You can also set the environment variable 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 # In this way, you can directly use node to start the HTTP Server.