buildkit

package
v0.17.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Overview

converts a railpack build plan to a BuildKit LLB state and image config

for platforms: used by `ghcr.io/railwayapp/railpack-frontend` to accept railpack plans via BuildKit

Index

Constants

View Source
const (
	WorkingDir = "/app"
)

Variables

This section is empty.

Functions

func Build

func Build(ctx context.Context, c client.Client) (*client.Result, error)

func BuildWithBuildkitClient

func BuildWithBuildkitClient(appDir string, plan *plan.BuildPlan, opts BuildWithBuildkitClientOptions) error

func ParsePlatformWithDefaults added in v0.9.0

func ParsePlatformWithDefaults(platformStr string) (specs.Platform, error)

ParsePlatformWithDefaults parses a platform string and returns the corresponding specs.Platform. If the input is empty, it defaults to a Linux platform that matches the host architecture.

This function handles the common case where we need to map host platforms to container platforms. We cannot use platforms.DefaultSpec() directly because it returns the host platform (e.g., darwin/arm64/v8 on macOS), but container base images only support Linux platforms. Instead, we map the host architecture to the corresponding Linux container platform to provide optimal performance while ensuring compatibility with container runtimes.

Examples:

  • "" -> linux/amd64 (on Intel hosts) or linux/arm64/v8 (on ARM hosts)
  • "linux/amd64" -> linux/amd64
  • "linux/arm64" -> linux/arm64
  • "linux/arm64/v8" -> linux/arm64/v8

func StartFrontend

func StartFrontend()

Types

type BuildWithBuildkitClientOptions

type BuildWithBuildkitClientOptions struct {
	ImageName    string
	DumpLLB      bool
	OutputDir    string
	ProgressMode string
	SecretsHash  string
	Secrets      map[string]string
	Platform     string
	ImportCache  string
	ExportCache  string
	CacheKey     string
	GitHubToken  string
}

type ConvertPlanOptions

type ConvertPlanOptions struct {
	BuildPlatform specs.Platform

	// Hash of all the secrets values that can be used to invalidate the layer cache when a secret changes
	SecretsHash string

	// Unique value prepended to all cache mount keys
	CacheKey string

	// BuildKit session ID
	SessionID string

	// Token used to make authenticated API requests to GitHub to increase rate limits
	GitHubToken string
}

type Image

type Image struct {
	specs.Image

	// Config defines the execution parameters which should be used as a base when running a container using the image.
	Config specs.ImageConfig `json:"config,omitempty"`

	// Variant defines platform variant. To be added to OCI.
	Variant string `json:"variant,omitempty"`
}

Image is the JSON structure which describes some basic information about the image. This provides the `application/vnd.oci.image.config.v1+json` mediatype when marshalled to JSON.

func ConvertPlanToLLB

func ConvertPlanToLLB(plan *p.BuildPlan, opts ConvertPlanOptions) (*llb.State, *Image, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL