compose

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const GB = 1 << 30 // 1 GB in bytes

Variables

This section is empty.

Functions

func CreateComposeFile

func CreateComposeFile(nodeName string, config NetworkConfig, extraServiceNames []string, extraServiceConfigs []NetworkConfig, cwd string) (string, error)

func EthereumChain added in v0.4.0

func EthereumChain(network string) string

EthereumChain returns the chain ("mainnet" or "sepolia") the Ethereum stack named by network runs on.

func RemoveInitContainersAndVolumes

func RemoveInitContainersAndVolumes() error

RemoveInitContainersAndVolumes removes all containers that match "init-config-*" and their associated volumes, deletes volumes with the label "nodevin.init.volume", and anonymous volumes created within the last minute.

func ResolveCheckpointSyncURL added in v0.3.0

func ResolveCheckpointSyncURL(consensusClient string) (string, error)

ResolveCheckpointSyncURL returns the validated --checkpoint-sync-url for a consensus client. It is required for every consensus client: Lighthouse and Teku refuse to sync from genesis at all, and genesis sync is impractically slow and unsafe for the rest. nodevin deliberately has no default endpoint - which third party to trust for checkpoint data is the user's call. Returns "" for consensusClient "none".

func SelectedConsensusClient added in v0.3.0

func SelectedConsensusClient() (string, error)

SelectedConsensusClient resolves --consensus-client, defaulting to lighthouse (currently the largest share of Ethereum mainnet consensus traffic). Unlike --ord/--ipfs-cluster, this is deliberately on by default: an execution client cannot sync at all post-Merge without a paired consensus client driving it over the Engine API, so leaving this off by default would produce a node that looks like it started but never does anything. Pass --consensus-client=none to run execution-only.

Exported since pkg/nodes/ethereum needs it too, to decide whether to wire up the extra consensus-client service and which of the five builder functions below to call.

func SelectedExecutionClient added in v0.3.0

func SelectedExecutionClient() (string, error)

SelectedExecutionClient resolves --execution-client, defaulting to reth (the broadest-compatibility pick per the pairing doc: no glibc issues, GPG-verified release, and the client Base's own image is built on).

func WithCheckpointSync added in v0.3.0

func WithCheckpointSync(consensusClient, chain, checkpointURL, command string) (string, error)

WithCheckpointSync returns command (a consensus client's base command) set up to start from the checkpoint provider at checkpointURL.

Every client but Nimbus just takes a flag. Nimbus's own checkpoint flags (--external-beacon-api-url with --trusted-block-root) rely on the provider serving light-client data, which public providers often don't - Nimbus then silently falls back to syncing from genesis. Its supported route is the separate `trustedNodeSync` subcommand, run once against an empty database, so for Nimbus the command becomes a small wrapper that runs it first. It never deletes anything that was there before: it only runs when there is no database yet, and only cleans up the partial one its own failed run created.

Types

type ComposeFile

type ComposeFile struct {
	//Version  string                    `yaml:"version"`
	Services map[string]Service        `yaml:"services"`
	Networks map[string]NetworkDetails `yaml:"networks"`
	Volumes  map[string]VolumeDetails  `yaml:"volumes"`
}

ComposeFile defines the top-level structure of the Docker Compose file.

type Deploy

type Deploy struct {
	Resources Resources `yaml:"resources,omitempty"`
}

Deploy holds the resource deployment configuration for a service.

type Healthcheck

type Healthcheck struct {
	Test        []string `yaml:"test"`
	Interval    string   `yaml:"interval"`
	Timeout     string   `yaml:"timeout"`
	Retries     int      `yaml:"retries"`
	StartPeriod string   `yaml:"start_period,omitempty"`
}

Healthcheck defines the parameters for a health check.

type NetworkConfig

type NetworkConfig struct {
	Image         string
	Version       string
	ContainerName string
	Command       string
	// CommandIsIntentionallyEmpty marks that this network's Command is meant
	// to be empty (e.g. ipfs/ipfs-cluster rely on the image's own baked-in
	// entrypoint), so a generic "Command must be non-empty" check doesn't
	// need a hardcoded per-network allowlist to know that's expected.
	CommandIsIntentionallyEmpty bool
	Restart                     string
	Ports                       []string
	Volumes                     []string
	Networks                    []string
	Deploy                      Deploy
	Environment                 map[string]string
	NetworkDefs                 map[string]NetworkDetails
	VolumeDefs                  map[string]VolumeDetails
	LocalPath                   string
	SnapshotSyncCID             string
	LocalChainDataPath          string
	SnapshotDataFilename        string
	SnapshotSyncCommand         string
}

NetworkConfig holds the configuration used to override or define services.

func GetBitcoinNetworkComposeConfig

func GetBitcoinNetworkComposeConfig(network string) (NetworkConfig, error)

func GetDogecoinNetworkComposeConfig added in v0.1.1

func GetDogecoinNetworkComposeConfig(network string) (NetworkConfig, error)

func GetEthereumClassicNetworkComposeConfig added in v0.2.0

func GetEthereumClassicNetworkComposeConfig(network string) (NetworkConfig, error)

func GetEthereumNetworkComposeConfig added in v0.3.0

func GetEthereumNetworkComposeConfig(network string) (NetworkConfig, error)

GetEthereumNetworkComposeConfig builds the execution client's compose config for "ethereum" (mainnet) or "ethereum-testnet" (Sepolia).

func GetIpfsClusterNetworkComposeConfig added in v0.0.8

func GetIpfsClusterNetworkComposeConfig(network string) (NetworkConfig, error)

func GetKuboNetworkComposeConfig added in v0.0.7

func GetKuboNetworkComposeConfig(network string) (NetworkConfig, error)

func GetLighthouseNetworkComposeConfig added in v0.3.0

func GetLighthouseNetworkComposeConfig(network string) (NetworkConfig, error)

GetLighthouseNetworkComposeConfig builds the compose config for Lighthouse paired with whichever execution client --execution-client selects, on mainnet ("lighthouse") or Sepolia ("lighthouse-testnet").

The execution client's host data directory is mounted read-only and the JWT flag points at the shared jwt.hex: a consensus client must never generate its own secret, or it would never authenticate with the execution client (see node-images' docs/ethereum-execution-consensus-pairing.md). The chain is named with --network, which the entrypoint only defaults when absent.

func GetLitecoinNetworkComposeConfig

func GetLitecoinNetworkComposeConfig(network string) (NetworkConfig, error)

func GetLodestarNetworkComposeConfig added in v0.3.0

func GetLodestarNetworkComposeConfig(network string) (NetworkConfig, error)

GetLodestarNetworkComposeConfig builds the compose config for Lodestar paired with whichever execution client --execution-client selects. See GetLighthouseNetworkComposeConfig and node-images' docs/ethereum-execution-consensus-pairing.md for the shared reasoning.

func GetNimbusNetworkComposeConfig added in v0.3.0

func GetNimbusNetworkComposeConfig(network string) (NetworkConfig, error)

GetNimbusNetworkComposeConfig builds the compose config for Nimbus paired with whichever execution client --execution-client selects. See GetLighthouseNetworkComposeConfig and node-images' docs/ethereum-execution-consensus-pairing.md for the shared reasoning.

Nimbus's (Nim/confutils) CLI only accepts --flag=value - a space-separated "--flag value" is silently misparsed as two separate tokens. The "=" below is required, not stylistic. The entrypoint prepends --network=mainnet and Nimbus uses the last occurrence of a repeated flag, so naming the chain here overrides it.

func GetOrdLitecoinNetworkComposeConfig

func GetOrdLitecoinNetworkComposeConfig(network string) (NetworkConfig, error)

func GetOrdNetworkComposeConfig

func GetOrdNetworkComposeConfig(network string) (NetworkConfig, error)

func GetPrysmNetworkComposeConfig added in v0.3.0

func GetPrysmNetworkComposeConfig(network string) (NetworkConfig, error)

GetPrysmNetworkComposeConfig builds the compose config for Prysm paired with whichever execution client --execution-client selects. See GetLighthouseNetworkComposeConfig and node-images' docs/ethereum-execution-consensus-pairing.md for the shared reasoning.

Prysm selects its chain with a flag per network (--mainnet, --sepolia) and refuses more than one ("cannot use more than one network flag at the same time"). Its entrypoint always prepends --mainnet, so a Sepolia stack bypasses the entrypoint's flag injection - by starting the binary through gosu - and passes the flags the entrypoint would have set itself.

func GetTekuNetworkComposeConfig added in v0.3.0

func GetTekuNetworkComposeConfig(network string) (NetworkConfig, error)

GetTekuNetworkComposeConfig builds the compose config for Teku paired with whichever execution client --execution-client selects. See GetLighthouseNetworkComposeConfig for the shared reasoning.

Unlike Lighthouse/Prysm/Lodestar, Teku has no "beacon"/"bn" subcommand, and its execution flags are --ee-endpoint / --ee-jwt-secret-file.

type NetworkDetails

type NetworkDetails struct {
	Driver string `yaml:"driver"`
}

NetworkDetails defines the network configuration for a service.

type ResourceDetails

type ResourceDetails struct {
	CPUs   string `yaml:"cpus,omitempty"`
	Memory string `yaml:"memory,omitempty"`
}

ResourceDetails defines CPU and memory limits and reservations.

type Resources

type Resources struct {
	Limits       ResourceDetails `yaml:"limits,omitempty"`
	Reservations ResourceDetails `yaml:"reservations,omitempty"`
}

Resources defines resource limits and reservations for a service.

type Service

type Service struct {
	Image         string                               `yaml:"image"`
	ContainerName string                               `yaml:"container_name"`
	User          string                               `yaml:"user,omitempty"`
	Restart       string                               `yaml:"restart"`
	Command       string                               `yaml:"command"`
	Entrypoint    string                               `yaml:"entrypoint,omitempty"`
	Ports         []string                             `yaml:"ports"`
	Volumes       []string                             `yaml:"volumes"`
	Networks      []string                             `yaml:"networks"`
	Healthcheck   *Healthcheck                         `yaml:"healthcheck,omitempty"`
	Environment   map[string]string                    `yaml:"environment,omitempty"`
	DependsOn     map[string]ServiceDependsOnCondition `yaml:"depends_on,omitempty"`
	Deploy        *Deploy                              `yaml:"deploy,omitempty"`
}

Service defines the configuration of a service in the Docker Compose file.

type ServiceDependsOnCondition

type ServiceDependsOnCondition struct {
	Condition string `yaml:"condition"`
}

ServiceDependsOnCondition defines the health condition for depends_on.

type VolumeDetails

type VolumeDetails struct {
	Labels map[string]string `yaml:"labels"`
}

VolumeDetails defines the volume configuration for a service.

Jump to

Keyboard shortcuts

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