monolith

package module
v0.0.1-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

monolith

CI Release

Lightweight Linux VMs on macOS (Apple Silicon), built on Apple's Virtualization.framework, plus Colima-style Docker, containerd and Kubernetes hosts.

  • monolith vm: Kata (default) or Alpine VMs that boot in seconds, with pause, suspend-to-disk and several network modes.
  • monolith docker: Docker Engine or containerd hosts for the CLI on your Mac, with docker contexts, localhost port forwarding (TCP and UDP), /Users bind mounts with file-change events, pause/resume to disk, optional Rosetta for amd64 images, and optional Kubernetes (k3s).
  • monolith network: named networks shared between VMs.

Install

Requires macOS on Apple Silicon:

curl -fsSL https://raw.githubusercontent.com/bubunyo/monolith/master/install.sh | bash

The script downloads the latest release, checks it against the release's SHA-256 checksums and its code signature, and installs monolith to /usr/local/bin (using sudo if needed). Options, as environment variables for the bash side of the pipe:

curl -fsSL https://raw.githubusercontent.com/bubunyo/monolith/master/install.sh | MONOLITH_VERSION=v0.1.0 MONOLITH_INSTALL_DIR=~/.local/bin bash

To install by hand, download monolith_<version>_darwin_arm64.tar.gz and checksums.txt from Releases, run shasum -a 256 -c checksums.txt, and copy the binary onto your PATH. If macOS then refuses to run it ("cannot be opened because the developer cannot be verified"), the release wasn't notarized and a browser added the quarantine flag: xattr -d com.apple.quarantine /path/to/monolith.

Build from source

Needs Go (see go.mod) and Xcode command line tools:

make build    # ./bin/monolith, codesigned with entitlements.plist
make test     # unit tests

make build signs ad-hoc unless .codesign_identity names a certificate (see docs/codesigning.md). Don't use a bare go build: without the virtualization entitlement the binary is killed on launch.

Quick start

monolith vm run dev                 # boot a VM and attach to its console (Ctrl+] then q to detach)
monolith docker start               # a Docker host; the docker CLI's context switches to it
docker run --rm -it busybox sh
monolith docker start --name k8s --kubernetes
kubectl get nodes

Documentation

Documentation

Index

Constants

View Source
const (
	LvlTrace = iota
	LvlInfo
	LvlWarn
	LvlError
)

Log level constants — numeric for comparison, string labels for output.

View Source
const EntitlementHostNetworking = "com.apple.vm.networking"

EntitlementHostNetworking is the entitlement Apple requires for using VZBridgedNetworkDeviceAttachment (i.e. host/bridged network mode).

Variables

This section is empty.

Functions

func CachePath

func CachePath(elem ...string) (string, error)

CachePath returns a path under the monolith cache root, ~/.cache/monolith. It does not create anything.

func EnsureLogReadable

func EnsureLogReadable(path, what, name string) error

EnsureLogReadable returns a friendly error if the log file is missing.

func HasEntitlement

func HasEntitlement(key string) bool

HasEntitlement reports whether the currently running binary has been codesigned with the given entitlement key set to true.

The result is cached for the lifetime of the process. On any error reading the signature (binary not signed, codesign missing, etc.) it returns false. This is intended for best-effort pre-flight checks; the authoritative enforcement happens inside Virtualization.framework at VM startup.

func OwnCodeRequirement

func OwnCodeRequirement() (string, error)

OwnCodeRequirement returns a code signing requirement that matches only the currently running binary (`cdhash H"<hash>"`). Network daemons and VM daemons run the same binary, so each side uses this to authenticate the other when sharing a vmnet network over XPC. Rebuilding or re-signing the binary changes the hash, so daemons from an older build won't match.

func ProcessAlive

func ProcessAlive(pid int) bool

ProcessAlive checks if a process with the given PID is still running. On Unix, sending signal 0 to a process checks for existence without actually sending a signal.

func StreamLogFile

func StreamLogFile(path string, out io.Writer, opts TailOptions) error

StreamLogFile prints the contents of the log file at path to out, with optional tail/follow semantics analogous to `tail -F`. When Follow is true, it keeps reading the file as the daemon appends to it. The function exits when out returns an error (e.g. the user closes stdout) or, if Follow is false, after the existing content has been written.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger writes structured log lines with timestamps and levels. It supports multiple output sinks, each with an independent minimum level. It is safe for concurrent use.

func NewLogger

func NewLogger(w io.Writer) *Logger

NewLogger creates a Logger that writes all levels to w.

func (*Logger) AddSink

func (l *Logger) AddSink(w io.Writer, minLevel int)

AddSink adds an additional output writer that receives messages at or above minLevel.

func (*Logger) Error

func (l *Logger) Error(format string, args ...any)

Error logs at ERR level.

func (*Logger) Info

func (l *Logger) Info(format string, args ...any)

Info logs at INF level.

func (*Logger) Trace

func (l *Logger) Trace(format string, args ...any)

Trace logs at TRC level. Used for verbose/diagnostic output such as packet monitors.

func (*Logger) Warn

func (l *Logger) Warn(format string, args ...any)

Warn logs at WRN level.

type TailOptions

type TailOptions struct {
	// Lines is the number of trailing lines to print before streaming.
	// Zero means "print everything from the start of the file".
	// A negative value means "skip the existing backlog entirely".
	Lines int
	// Follow keeps reading new content appended to the file until ctx
	// is cancelled or the writer to out returns an error.
	Follow bool
}

TailOptions controls how StreamLogFile reads a log file.

Directories

Path Synopsis
cli
docker
Package docker implements `monolith docker`: container host VMs for the docker CLI (docker engine) or nerdctl (containerd engine), in the style of Colima.
Package docker implements `monolith docker`: container host VMs for the docker CLI (docker engine) or nerdctl (containerd engine), in the style of Colima.
vm
cmd
monolith command

Jump to

Keyboard shortcuts

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