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

§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

Structs§

RuntimeInfo
Information about a runtime template

Enums§

Runtime
Supported runtime environments

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