Skip to main content

Module templates

Module templates 

Source
Expand description

Runtime templates for ZLayer builder

This module provides pre-built Dockerfile templates for common runtimes, allowing users to build container images without writing Dockerfiles.

§Usage

Templates can be used via the zlayer build command:

# Use a specific runtime template
zlayer build --runtime node20

# Auto-detect runtime from project files
zlayer build --detect-runtime

§Available Runtimes

  • Node.js 20 (node20): Production-ready Node.js 20 with Alpine base
  • Node.js 22 (node22): Production-ready Node.js 22 with Alpine base
  • Python 3.12 (python312): Python 3.12 slim with pip packages
  • Python 3.13 (python313): Python 3.13 slim with pip packages
  • Rust (rust): Static binary build with musl
  • Go (go): Static binary build with Alpine
  • Deno (deno): Official Deno runtime
  • Bun (bun): Official Bun runtime
  • Windows Nanoserver (windows-nanoserver): Minimal Windows base for self-contained binaries; no package managers / no PowerShell
  • Windows Server Core (windows-servercore): Larger Windows base with PowerShell bundled; required for chocolatey / winget / full .NET SDK

§Auto-Detection

The detect_runtime function can automatically detect the appropriate runtime based on files present in the project directory:

  • package.json -> Node.js (unless Bun or Deno indicators present)
  • bun.lockb -> Bun
  • deno.json or deno.jsonc -> Deno
  • Cargo.toml -> Rust
  • requirements.txt, pyproject.toml, setup.py -> Python
  • go.mod -> Go
  • *.sln / *.csproj / *.vcxproj / project.json -> Windows Server Core
  • *.exe (with no Linux indicators) -> Windows Nanoserver

Auto-detection is a hint. Explicit overrides (os: field, --platform CLI flag) always win — see resolve_runtime.

Structs§

RuntimeInfo
Information about a runtime template

Enums§

Runtime
Supported runtime environments
WasmTargetHint
Hint for the kind of WebAssembly artifact a project produces.

Functions§

detect_runtime
Detect the runtime from files in the given directory.
detect_runtime_with_version
Detect runtime with version hints from project files.
get_template
Get template content for a runtime
get_template_by_name
Get template content by runtime name
list_templates
List all available templates
resolve_runtime
Resolve runtime from either explicit name or auto-detection