compose

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package compose writes a docker-compose.yml for CashPilot services.

It exists so a machine that earns does not have to keep CashPilot running to keep earning: the user saves a compose file, runs it with `docker compose up -d` (or Podman, or Portainer, or a box's own GitOps), and CashPilot can still see those containers afterwards because the file carries the same cashpilot.* labels the app's own deploy writes.

Two rules shape everything here, and both are about what the exported file must NOT be.

It must not be weaker than a CashPilot deploy. A file that drops the memory ceiling, the capability set or the TUN device produces a container that looks identical and is either less protected or silently unable to earn, which is the worst kind of difference: invisible. So the export writes the hardening the web CashPilot worker deploys with (app/orchestrator.py) — every capability dropped, only the ones the entry declares added back, no new privileges, a PID ceiling, the declared resource limits, and the declared stop grace period. That is a real, running configuration for these images rather than an invention here, and it is the same set Desktop's own deploy path applies (internal/runtime/hardening.go), so a container started from the file is exactly as protected as one started from the dashboard.

And it must not contain a single credential. Everything the user has to supply is written as a ${VAR} placeholder, never a value, so the file is safe to keep in a repository, paste into a ticket or send to the other half of a fleet. Compose fills the placeholders from a .env file beside it at run time.

The structure mirrors the web CashPilot's app/compose_generator.py, which is the behaviour this has to match: same container names, same labels, same logging rotation, same per-architecture image choice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(src Source, slugs []string, opts Options) (string, error)

Generate returns the docker-compose.yml text for the given services.

It refuses rather than degrades. An unknown slug, a retired service, a service with no image and an unknown architecture are all errors, because each of them would otherwise produce a runnable-looking file that cannot earn: a compose file silently missing one of the three services the user selected is indistinguishable from one that deployed them all.

func HostFamily

func HostFamily(goarch string) string

HostFamily is the family of the machine this copy of CashPilot is running on, or "" when it is an architecture no catalog image publishes a separate build for.

It takes runtime.GOARCH rather than reading it so the mapping is testable on any machine. The three names Go uses for the families the catalog knows are the same three the catalog uses, and everything else (386, riscv64, ppc64le, s390x) has no per-architecture build in any entry, so "" — let the manifest decide — is the honest answer for it rather than a guess.

Types

type Options

type Options struct {
	// Arch is the architecture family the file is for: amd64, arm64 or arm. Empty
	// means "whatever the machine running the file resolves from the image manifest",
	// which is right for every entry except the ones whose ARM builds Docker cannot
	// pick itself. Anything else is an error: a typo must not quietly produce an
	// amd64 file for a Raspberry Pi.
	Arch string
	// Hostname fills the {hostname} placeholder catalog defaults use for device
	// names. Empty leaves the placeholder's own default text alone.
	Hostname string
}

Options are the choices the caller has to make for the export, because the file is written for a machine that is not necessarily this one.

type Source

type Source interface {
	Get(slug string) (catalog.Service, bool)
}

Source is the slice of the catalog the exporter needs. Taking an interface keeps the generator testable against hand-built entries with no services/ directory on disk; *catalog.Catalog satisfies it.

Jump to

Keyboard shortcuts

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