Skip to main content
Community Scripts logo
Function reference

Runtimes and tools

Reference for the language runtime and tool installers in lib/runtime.func - Node.js, uv/Python, Go, Rust, Ruby, Java, .NET, PHP, Docker, FFmpeg and more.

Source: lib/runtime.func. It is loaded through lib/tools.func on every container that is not Alpine. Alpine containers load lib/alpine.func instead, which carries its own setup_yq, setup_adminer, setup_uv, setup_java, setup_go and setup_composer; the rest of this page does not exist there (see Alpine).

FunctionPurpose
setup_nodejsNode.js from NodeSource, npm, global modules
setup_uvuv, and optionally a Python version
setup_nltkNLTK data packages without Python
setup_goGo from go.dev
setup_rustRust through rustup, optional crates
rust_prune_toolchainsRemove all Rust toolchains but the default
setup_rubyRuby through rbenv, optionally Rails
setup_javaTemurin JDK
setup_java_memorySize the JVM heap from the container's memory
setup_dotnet.NET SDK or runtime
setup_phpPHP with modules, Apache or FPM
setup_composerComposer
get_php_fpm_socketPath of the active PHP-FPM socket
nginx_enable_siteEnable an nginx site, test, restart
setup_adminerAdminer
setup_dockerDocker Engine, optionally Portainer
ensure_dockerDocker precondition for add-on scripts
setup_ffmpegFFmpeg from the distribution, a prebuilt build or source
setup_gsGhostscript from source
setup_imagemagickImageMagick 7 from source
setup_yqmikefarah's yq

There is no setup_python. Python comes from the distribution or from setup_uv with PYTHON_VERSION.

How these functions are called

Most installers take no positional arguments. They read environment variables, which scripts pass as a prefix on the same line:

NODE_VERSION="24" NODE_MODULE="pnpm" setup_nodejs

Every variable has a default, so a bare setup_nodejs is valid. The functions are idempotent: called again from update_script() they update what is installed, or switch versions when the requested one differs.

All functions return their status unless noted. Install scripts run under catch_errors, so a non-zero return stops the script with that code. The numbers are explained in Exit codes.

Node.js

setup_nodejs

Installs Node.js from the NodeSource repository, brings npm up to date and installs global npm modules.

[NODE_VERSION=<major>] [NODE_MODULE=<list>] setup_nodejs
VariableDefaultMeaning
NODE_VERSION24Node.js major version. It selects the repository https://deb.nodesource.com/node_<version>.x
NODE_MODULEemptyComma-separated global modules, each optionally with a version: pnpm, pnpm@12, yarn,corepack, @postlight/parser@latest
NODE_COREPACK_ENABLE1Run corepack enable after installing corepack. Any other value skips it
NPM_VERSIONlatestnpm version installed with npm install -g npm@<version>
NODE_MAX_OLD_SPACE_SIZEunsetHeap limit in MB, see below
NODE_OPTIONSunsetIf it already contains --max-old-space-size, the heap limit is left alone
var_ramset by the frameworkFallback for the heap calculation when /proc/meminfo cannot be read

What it changes besides installing packages:

  • The working directory becomes /opt.
  • COREPACK_ENABLE_DOWNLOAD_PROMPT=0 and NPM_CONFIG_UPDATE_NOTIFIER=false are exported.
  • NODE_OPTIONS is exported with --max-old-space-size. The value is NODE_MAX_OLD_SPACE_SIZE if set, otherwise 75 % of the container's memory, clamped to 1024..12288 MB. Other flags already in NODE_OPTIONS are kept.
  • For npm 11 and newer, dangerously-allow-all-scripts is set to true; for npm 12 and newer, allow-git and allow-remote are set to all. Both are written to the global and the user npm config.
  • If pnpm is present, strictDepBuilds is set to false and the fetch timeout is raised. If yarn is present, its network timeout is raised.

Module rules:

  • A bare pnpm installs pnpm@^10. Name a version (pnpm@12) to get another major.
  • From Node.js 25 on, corepack is added to the list automatically.
  • If corepack is in the list it is installed and enabled first, and pnpm and yarn are then provided through corepack prepare ... --activate instead of npm.
  • A module that fails to install produces a warning, not an error. After the loop every unscoped module is checked with command -v and reinstalled if its binary is missing.

Version changes: with a different major installed, Node.js is purged and reinstalled from the new repository. That also uninstalls the global npm modules, so list the ones the app needs in NODE_MODULE. If another package depends on nodejs, the function upgrades in place instead and refuses a downgrade.

ReturnsWhen
0Installed or updated
250The NodeSource repository could not be set up
100APT or package failure
127/opt is not usable, or node / npm is missing after installation
1npm could not be restored, a downgrade was refused, or an in-place upgrade would remove other packages

Example from ct/archivebox.sh:

NODE_VERSION="22" NODE_MODULE="@postlight/parser@latest,single-file-cli@latest" setup_nodejs

ct/iobroker.sh pins npm: NODE_VERSION="24" NPM_VERSION="11" setup_nodejs.

Python

setup_uv

Installs uv to /usr/local/bin/uv from its GitHub release and optionally installs a Python version with it.

[PYTHON_VERSION=<version>] [UV_PROJECT_DIR=<dir>] setup_uv
VariableDefaultMeaning
PYTHON_VERSIONunsetIf set, runs uv python install <version>
UV_VERSIONunsetExact uv version to install
UV_PROJECT_DIRunsetProject directory. If its pyproject.toml or uv.toml sets required-version, that decides the uv version: an exact pin is used as is, a range resolves to the newest release inside it
USE_UVXNOYES also writes /usr/local/bin/uvx, a wrapper for uv tool run
UV_HTTP_TIMEOUT600Exported for uv itself

The uv version is chosen in this order: UV_VERSION, the project's required-version, the latest release. Variables that uv itself reads pass through to uv python install; ct/authentik.sh sets UV_PYTHON_INSTALL_DIR this way.

Supported architectures are x86_64, aarch64 and i686.

ReturnsWhen
0Installed, upgraded or already at the target version
236Unsupported architecture
7The latest version could not be fetched, or the download failed
251The tarball could not be extracted
127No uv binary in the tarball
252The binary or the uvx wrapper could not be written
150uv python install failed

Example from ct/beaverhabits.sh:

PYTHON_VERSION="3.14" UV_PROJECT_DIR="/opt/beaverhabits" setup_uv

setup_nltk

Downloads NLTK data packages straight from the nltk_data index, without running Python.

setup_nltk "<package ids>" [target_dir]
ArgumentDefaultMeaning
package idsrequiredSpace-separated NLTK package IDs in one string
target_dir/usr/share/nltk_dataDirectory the packages are placed in

Returns 0 when every package was downloaded and 1 when the index could not be fetched or any package failed. The remaining packages are still attempted.

Example from ct/paperless-ngx.sh:

setup_nltk "snowball_data stopwords punkt_tab" "/usr/share/nltk_data"

Go

setup_go

Installs Go from the official tarball to /usr/local/go and links go and gofmt into /usr/local/bin.

[GO_VERSION=<version>] setup_go
VariableDefaultMeaning
GO_VERSIONlatestlatest, a full version such as 1.22.2, or a bare major.minor such as 1.22, which is resolved to the newest patch release of that line

Because a bare major.minor is accepted, the go directive of a go.mod can be passed directly.

ReturnsWhen
0Installed, or already at the requested version
236Architecture is neither x86_64 nor aarch64
250The version could not be resolved or the download failed
251The tarball could not be extracted
100jq, needed to resolve a major.minor, could not be installed
1The old version could not be removed

Example from ct/bitmagnet.sh:

GO_VERSION="$(grep -m1 '^go ' /opt/bitmagnet/go.mod | awk '{print $2}')" setup_go

Rust

setup_rust

Installs Rust through rustup, or updates the toolchain if rustup is already there, and installs global crates.

[RUST_TOOLCHAIN=<toolchain>] [RUST_PROFILE=<profile>] [RUST_CRATES=<list>] setup_rust
VariableDefaultMeaning
RUST_TOOLCHAINstableToolchain to install and set as default
RUST_PROFILEdefaultrustup profile for a fresh install, for example minimal
RUST_CRATESemptyComma-separated crates for cargo install, each optionally with a version: monolith, wasm-pack@0.12.1
HOMEset by the shellCargo lives in $HOME/.cargo

What it changes besides installing:

  • $HOME/.cargo/bin is added to PATH for the current script. A fresh install also adds it to $HOME/.profile and writes /etc/profile.d/99-cargo.sh.
  • [net] retry = 5 is appended to the cargo config if it has no [net] section.
  • When RUST_CRATES is set, every binary in $HOME/.cargo/bin is linked into /usr/local/bin, so systemd units find it.
  • At the end it calls rust_prune_toolchains.
ReturnsWhen
0Installed or updated
7The rustup installer could not be downloaded or failed
127rustc is missing after installation
250The Rust version could not be determined
150A toolchain or crate failed to install

Example from install/linkwarden-install.sh:

RUST_CRATES="monolith" setup_rust

ct/authentik.sh uses the minimal profile: RUST_PROFILE="minimal" RUST_TOOLCHAIN="stable" setup_rust.

rust_prune_toolchains

Uninstalls every rustup toolchain except the default one. A source tree with a rust-toolchain.toml makes rustup install that exact version during a build and never remove it; this frees the space again.

rust_prune_toolchains

No arguments, no variables. Returns 0, also when rustup is not installed.

No script in ProxmoxVE calls it directly; setup_rust runs it at the end of every call. Call it yourself after a build that came after setup_rust.

Ruby

setup_ruby

Installs rbenv and ruby-build into $HOME/.rbenv, compiles the requested Ruby version and sets it as the global version.

[RUBY_VERSION=<version>] [RUBY_INSTALL_RAILS=false] setup_ruby
VariableDefaultMeaning
RUBY_VERSION3.4.4Full Ruby version
RUBY_INSTALL_RAILStruetrue runs gem install rails afterwards. A failure there only warns
HOMEset by the shellLocation of .rbenv and of the profile files that get the rbenv PATH lines. The directory is created if missing

Ruby is built from source, which takes several minutes. If the requested version is already the rbenv global version the function returns immediately.

ReturnsWhen
0Installed or already at the requested version
100APT is not working or no build dependency is available
7rbenv or ruby-build could not be downloaded
251An archive could not be extracted
150rbenv or Ruby failed to build

Example from ct/discourse.sh:

RUBY_VERSION="${RUBY_TARGET:-4.0.7}" RUBY_INSTALL_RAILS="false" setup_ruby

Java

setup_java

Installs the Temurin JDK from the Adoptium repository.

[JAVA_VERSION=<major>] setup_java
VariableDefaultMeaning
JAVA_VERSION21JDK major version. The package installed is temurin-<version>-jdk

If a different Temurin JDK is installed it is purged first. The same version is upgraded through apt.

Returns 0 on success and 100 on any repository or package failure.

Example from ct/apache-guacamole.sh:

JAVA_VERSION="17" setup_java

setup_java_memory

Makes a Java service size its heap from the container's memory instead of the host's. For each unit it writes the drop-in /etc/systemd/system/<unit>.service.d/java-memory.conf. On every service start the drop-in reads MemTotal from /proc/meminfo and sets JAVA_TOOL_OPTIONS=-XX:MaxRAM=<MemTotal>k.

setup_java_memory <unit> [<unit> ...]
ArgumentMeaning
unitsystemd unit name without .service. Several can be given

The function does nothing and returns 0 unless all three conditions hold: the cgroup reports no memory limit (/sys/fs/cgroup/memory.max is max), /proc/meminfo is served by lxcfs, and systemd is running. It always returns 0.

No script in ProxmoxVE calls it yet. A call for a service named myapp looks like this:

setup_java_memory myapp

.NET

setup_dotnet

Installs a .NET SDK or runtime. Debian and Ubuntu 22.04 get it from packages.microsoft.com; Ubuntu 24.04 and newer get it from the distribution archive. Major versions install side by side, so an existing one is left alone.

[DOTNET_VERSION=<major>] [DOTNET_TYPE=sdk|runtime|aspnetcore] setup_dotnet
VariableDefaultMeaning
DOTNET_VERSION10Major version. 8.0 is accepted and treated as 8
DOTNET_TYPEsdksdk installs dotnet-sdk-<v>.0, runtime installs dotnet-runtime-<v>.0, aspnetcore installs aspnetcore-runtime-<v>.0
ReturnsWhen
0Installed or updated
65Invalid DOTNET_TYPE
100No Microsoft feed for this release, package not available, or apt failure

Example from install/shoko-install.sh:

DOTNET_VERSION="8" DOTNET_TYPE="aspnetcore" setup_dotnet

PHP and web server

setup_php

Installs PHP with a default module set, optional extra modules and optional Apache or FPM integration. Debian uses the Sury repository, Ubuntu the ondrej/php PPA.

[PHP_VERSION=<major.minor>] [PHP_FPM=YES] [PHP_APACHE=YES] [PHP_MODULE=<list>] setup_php
VariableDefaultMeaning
PHP_VERSION8.4Version as major.minor
PHP_MODULEemptyExtra modules, comma-separated, without the php<version>- prefix
PHP_FPMNOYES installs and enables php<version>-fpm
PHP_APACHENOYES installs apache2 and libapache2-mod-php<version> and enables the module
PHP_MEMORY_LIMIT512Mmemory_limit
PHP_UPLOAD_MAX_FILESIZE128Mupload_max_filesize
PHP_POST_MAX_SIZE128Mpost_max_size
PHP_MAX_EXECUTION_TIME300max_execution_time

Always installed: cli, common, bcmath, curl, dom, gd, gmp, intl, mbstring, readline, xml, zip, mysql, sqlite3, pgsql, redis, imagick, bz2, apcu, and opcache below PHP 8.5 (it is built in from 8.5 on). Modules that are part of php-common (ctype, fileinfo, iconv, tokenizer, pdo, exif and others) are filtered out of PHP_MODULE, and a module without a package is skipped with a notice.

Behaviour worth knowing:

  • If a different PHP version is installed it is removed first with apt purge "php*".
  • The four php.ini values are written to the CLI ini, and to the FPM and Apache ini when those are enabled.
  • With PHP_FPM=YES a systemd override sets RuntimeDirectory=php for the FPM service.
  • PHP_FPM and PHP_APACHE are compared against the literal YES.
ReturnsWhen
0Installed
100Repository or package failure, or the version is not in the repository
127php is missing afterwards or reports a different version than requested

Example from install/projectsend-install.sh:

PHP_VERSION="8.4" PHP_FPM="YES" PHP_MODULE="ldap,pcntl" setup_php

setup_composer

Installs Composer to /usr/local/bin/composer, or runs composer self-update if it is already there. Call it after setup_php.

setup_composer

No variables. It exports COMPOSER_ALLOW_SUPERUSER=1 and sets Composer's global process-timeout to 600.

ReturnsWhen
0Installed or updated
250The installer could not be downloaded
150The installer failed
127The binary is missing afterwards

Example from install/bookstack-install.sh:

setup_composer

get_php_fpm_socket

Prints the path of the PHP-FPM socket that exists on the system, for use in an nginx fastcgi_pass or a Caddy php_fastcgi line.

PHP_SOCK=$(get_php_fpm_socket)
VariableDefaultMeaning
PHP_VERSIONunsetIf set and /run/php/php<version>-fpm.sock exists, that path is returned. Otherwise the highest version found under /run/php

PHP-FPM has to be running; the socket only exists after the service has started. Returns 1 with an error when no socket is found.

Example from ct/paymenter.sh:

PHP_SOCK=$(get_php_fpm_socket)
sed -i "s|fastcgi_pass unix:.*|fastcgi_pass unix:${PHP_SOCK};|" /etc/nginx/sites-available/paymenter.conf

nginx_enable_site

Links a site from sites-available into sites-enabled, removes the packaged default site, runs nginx -t, enables the nginx unit and restarts it.

nginx_enable_site <site>
ArgumentMeaning
siteFile name below /etc/nginx/sites-available/. It is used as given, including any .conf suffix

Returns 1 when no name is given, the file does not exist or nginx -t fails. Otherwise it returns the result of the restart.

Example from ct/paymenter.sh:

nginx_enable_site paymenter.conf

setup_adminer

Installs Adminer. On Debian and Ubuntu it installs the adminer package, enables its Apache configuration with a2enconf adminer and reloads Apache, so Apache has to be present. The function also has an Alpine branch that downloads adminer.php to /var/www/localhost/htdocs/adminer/index.php.

setup_adminer

No variables.

ReturnsWhen
0Installed
150The Apache configuration could not be enabled or Apache did not reload
250The download failed (Alpine branch)

Example from install/linkwarden-install.sh:

if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
  setup_adminer
fi

Docker

setup_docker

Installs or updates Docker Engine, optionally installs Portainer, and on an existing installation offers to update running containers.

[USE_DOCKER_REPO=false] [DOCKER_PORTAINER=true] setup_docker
VariableDefaultMeaning
USE_DOCKER_REPOtruetrue, TRUE or 1 installs docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin and docker-compose-plugin from download.docker.com. Any other value installs docker.io from the distribution
DOCKER_PORTAINERunsettrue installs Portainer CE on ports 9000 and 9443, or offers its update
DOCKER_LOG_DRIVERjournaldLog driver written to /etc/docker/daemon.json. Only used when that file does not exist yet
DOCKER_LXCFS_VISIBILITYnoyes or true registers a runc wrapper as Docker's default runtime so nested containers see the LXC container's memory and CPU limits instead of the host's
var_docker_lxcfsunsetSame switch, read when DOCKER_LXCFS_VISIBILITY is not set
DOCKER_NONINTERACTIVEunset1 or true suppresses every prompt

The header comment of the function also lists DOCKER_SKIP_UPDATES; the code does not read it.

Prompts: when Docker was already installed, the function pulls the image of every running container and, for each one whose image changed, asks whether to update it. Compose-managed containers are updated with docker compose pull and up -d; for standalone containers only the image is pulled. Each prompt answers itself with "no" after 60 seconds. The whole check is skipped when the run is unattended, when DOCKER_NONINTERACTIVE is set or when stdin is not a terminal.

The lxcfs option is described in core's Docker inside LXC. It never replaces an existing default-runtime.

Returns 0 on success and 100 when APT is not working or the Docker packages cannot be installed or updated.

Example from ct/docker.sh, which keeps an existing docker-ce installation on the official repository:

if dpkg-query -W -f='${Status}' docker-ce 2>/dev/null | grep -q "ok installed"; then
  USE_DOCKER_REPO="true" setup_docker
else
  setup_docker
fi

ensure_docker

Precondition check for add-on scripts that ship a Compose stack. If Docker and the Compose plugin are present it returns. If Docker is missing it asks Install Docker now? (y/N) and installs it: through setup_docker on Debian and Ubuntu, through apk on Alpine.

ensure_docker
VariableDefaultMeaning
APPthis scriptName used in the error messages
DOCKER_NONINTERACTIVEunset1 or true counts as an unattended run

This function exits the script instead of returning an error.

Exits withWhen
254Docker is missing and the run is unattended, or the user did not answer yes
237Docker is installed without the Compose plugin, the installation failed, or Docker or Compose is still unavailable afterwards

Returns 0 when Docker and Compose are available.

Example from tools/addon/dockge.sh:

function install() {
  ensure_docker

Media and tools

setup_ffmpeg

Installs FFmpeg in one of three ways: the distribution package, a prebuilt static build from BtbN/FFmpeg-Builds, or a build from source.

[FFMPEG_TYPE=<type>] [FFMPEG_VERSION=<version>] [FFMPEG_LICENSE=gpl|lgpl] setup_ffmpeg
VariableDefaultMeaning
FFMPEG_TYPErepoSee the table below
FFMPEG_VERSIONlatestgithub: latest (master) or a release line such as n7.1. Source builds: a git tag; latest picks the newest stable tag
FFMPEG_LICENSEgplgithub only: gpl or lgpl
FFMPEG_TYPEWhat you getInstalled to
repoapt install ffmpeg/usr/bin
githubPrebuilt static build for amd64 or arm64. binary is accepted as an old name for it/usr/local/bin
minimalSource build with x264, vpx, mp3/usr/local/bin
mediumminimal plus freetype, libass, opus, vorbis/usr/local/bin
fullmedium plus x265, dav1d, zlib, VA-API/usr/local/bin

Source builds use --enable-gpl --enable-nonfree and take a long time on a small container. Use repo unless the app needs a codec or version the distribution does not ship.

ReturnsWhen
0Installed
100The distribution package could not be installed
106Unsupported architecture for a github build
250A download failed or no source version could be determined
251An archive could not be extracted
150Configure, compile or install failed
65Unknown FFMPEG_TYPE

Examples: install/lychee-install.sh calls plain setup_ffmpeg; install/pinchflat-install.sh uses the prebuilt build:

FFMPEG_TYPE="binary" setup_ffmpeg

setup_gs

Builds the latest Ghostscript release from source and installs it system-wide. If the installed version is already current it does nothing.

setup_gs

No variables. If the latest version cannot be determined but gs is installed, the function keeps the existing one and returns 0.

ReturnsWhen
0Installed, or already current
250The version could not be determined and nothing is installed, or the download failed
251The archive could not be extracted
252The source directory is missing after extraction
150Configure, compile or install failed

Example from install/transmute-install.sh:

setup_gs

setup_imagemagick

Builds ImageMagick 7 from the latest GitHub source release and installs it to /usr/local. The binary is /usr/local/bin/magick; the source stays in /opt/imagemagick.

setup_imagemagick

No variables. It installs the build dependencies itself.

ReturnsWhen
0Installed
250The source could not be downloaded
251The source directory could not be entered
150Configure, compile or install failed

Example from install/lychee-install.sh:

setup_imagemagick

setup_yq

Installs the latest mikefarah/yq to /usr/local/bin/yq. A yq from another implementation is removed first.

setup_yq

No variables. If the installed version is already the latest it does nothing.

ReturnsWhen
0Installed, or already current
250The latest version could not be fetched or the download failed
252The binary could not be moved into place

Example from install/forgejo-runner-install.sh:

setup_yq

Internal functions

These are called by the functions above. Do not call them from a script.

FunctionUsed byWhat it does
_docker_is_noninteractivesetup_docker, ensure_dockerTrue when DOCKER_NONINTERACTIVE is set, the run is unattended or stdin is not a terminal
_docker_setup_lxcfs_visibilitysetup_dockerWrites /usr/local/bin/runc-lxcfs and registers it in daemon.json
_setup_npmsetup_nodejsInstalls npm@${NPM_VERSION:-latest} and reports the result in NPM_SETUP_VERSION
_cs_drop_pm_shimsetup_nodejsRemoves a pnpm, yarn or yarnpkg shim right before npm installs that module
_nodejs_in_place_simulatesetup_nodejsSimulates an in-place Node.js upgrade and fails if a dependent package would be removed
_cs_write_cargo_profilesetup_rustWrites /etc/profile.d/99-cargo.sh
_cs_write_cargo_netsetup_rustAppends [net] retry = 5 to the cargo config
_uv_required_versionsetup_uvReads required-version from a project's pyproject.toml or uv.toml
_uv_release_listsetup_uvLists uv releases, newest first
_uv_ver_gesetup_uvVersion comparison
_uv_pick_versionsetup_uvPicks the newest release that satisfies a version range
_install_uvx_wrappersetup_uvWrites /usr/local/bin/uvx