Documentation
¶
Overview ¶
Package templates provides utilities for generating Dockerfile templates based on different transport types (uvx, npx).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var RuntimeDefaults = map[TransportType]RuntimeConfig{ TransportTypeGO: { BuilderImage: "golang:1.25-alpine", AdditionalPackages: []string{"ca-certificates", "git"}, }, TransportTypeNPX: { BuilderImage: "node:22-alpine", AdditionalPackages: []string{"git", "ca-certificates"}, }, TransportTypeUVX: { BuilderImage: "python:3.13-slim", AdditionalPackages: []string{"ca-certificates", "git"}, }, }
RuntimeDefaults provides default configurations for each runtime type
Functions ¶
func GetDockerfileTemplate ¶
func GetDockerfileTemplate(transportType TransportType, data TemplateData) (string, error)
GetDockerfileTemplate returns the Dockerfile template for the specified transport type.
Types ¶
type RuntimeConfig ¶ added in v0.9.3
type RuntimeConfig struct {
// BuilderImage is the full image reference for the builder stage
// Examples: "golang:1.25-alpine", "node:22-alpine", "python:3.13-slim"
BuilderImage string `json:"builder_image" yaml:"builder_image"`
// AdditionalPackages lists extra packages to install in builder stage
// Examples for Alpine: ["git", "make", "gcc"]
// Examples for Debian: ["git", "build-essential"]
AdditionalPackages []string `json:"additional_packages,omitempty" yaml:"additional_packages,omitempty"`
}
RuntimeConfig defines the base images and versions for a specific runtime
func GetDefaultRuntimeConfig ¶ added in v0.9.3
func GetDefaultRuntimeConfig(transportType TransportType) RuntimeConfig
GetDefaultRuntimeConfig returns the default runtime configuration for a given transport type
func (*RuntimeConfig) Validate ¶ added in v0.12.3
func (rc *RuntimeConfig) Validate() error
Validate checks that all RuntimeConfig fields contain safe values that cannot cause unexpected behavior when interpolated into Dockerfile templates. An empty BuilderImage is allowed because it signals "use the default for this transport type" during config merging. It returns a combined error listing all invalid fields.
type TemplateData ¶
type TemplateData struct {
// MCPPackage is the name of the MCP package to run.
MCPPackage string
// MCPPackageClean is the package name with version suffix removed.
// For example: "@org/package@1.2.3" becomes "@org/package", "package@1.0.0" becomes "package"
// This field is automatically populated by GetDockerfileTemplate.
MCPPackageClean string
// CACertContent is the content of the custom CA certificate to include in the image.
CACertContent string
// IsLocalPath indicates if the MCPPackage is a local path that should be copied into the container.
IsLocalPath bool
// BuildArgs are the arguments to bake into the container's ENTRYPOINT at build time.
// These are typically required subcommands (e.g., "start") that must always be present.
// Runtime arguments passed via "-- <args>" will be appended after these build args.
BuildArgs []string
// BuildEnv contains environment variables to inject into the Dockerfile builder stage.
// These are used for configuring package managers (e.g., custom registry URLs).
// Keys must be uppercase with underscores, values are validated for safety.
BuildEnv map[string]string
// BuildAuthFiles contains auth file contents keyed by file type (npmrc, netrc, etc).
// These files are injected into the builder stage only for authentication.
BuildAuthFiles map[string]string
// RuntimeConfig specifies the base images and packages
// If nil, defaults for the transport type are used
RuntimeConfig *RuntimeConfig
}
TemplateData represents the data to be passed to the Dockerfile template.
type TransportType ¶
type TransportType string
TransportType represents the type of transport to use.
const ( // TransportTypeUVX represents the uvx transport. TransportTypeUVX TransportType = "uvx" // TransportTypeNPX represents the npx transport. TransportTypeNPX TransportType = "npx" // TransportTypeGO represents the go transport. TransportTypeGO TransportType = "go" )
func ParseTransportType ¶
func ParseTransportType(s string) (TransportType, error)
ParseTransportType parses a string into a transport type.