dockercmd

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dockercmd builds docker CLI argv slices. Builders are pure — no execution, no I/O — so the full command surface is testable without a server. cmd/* decides which context or host runs them.

Index

Constants

View Source
const (
	LabelProject    = "ferry.project"
	LabelService    = "ferry.service"
	LabelVersion    = "ferry.version"
	LabelPreview    = "ferry.preview"
	LabelConfigHash = "ferry.config-hash"
)

Ferry container labels; these drive ps, pruning, rollback and preview discovery — state lives on the server, not in local files.

View Source
const ProxyContainerName = "kamal-proxy"

ProxyContainerName is the kamal-proxy container name on each server.

Variables

This section is empty.

Functions

func Build

func Build(build *types.BuildConfig, image string) []string

Build builds `docker build` argv from the compose build section.

func BuildScript

func BuildScript(build *types.BuildConfig, image, ctxDir string) string

BuildScript renders the shell command for a host-side build: cd into the shipped context dir and build with "." as context, so compose-relative dockerfile paths resolve the same way they would locally.

func ConfigHash

func ConfigHash(svc types.ServiceConfig, image string, o RunOpts, env []byte) string

ConfigHash digests everything a container is created from — the full `docker run` argv (image, command, entrypoint, ports, volumes, healthcheck, labels, network) plus the merged env content — so a stateful service is recreated exactly when one of those inputs changes. The deploy version and the env-file temp path are excluded: they vary per deploy without changing the container; env changes register through the env content instead.

func ContextCreate

func ContextCreate(name string, s *config.Server) []string

ContextCreate builds argv to create a Docker context for a server.

func Labels

func Labels(svc types.ServiceConfig, o RunOpts) []string

Labels returns the ferry labels plus compose labels, sorted.

func ProxyDeploy

func ProxyDeploy(o ProxyDeployOpts) []string

ProxyDeploy builds the `kamal-proxy deploy` argv (to run via docker exec in the proxy container). It blocks until the new target passes health checks, then atomically swaps traffic and drains the old one — that is the whole zero-downtime story.

func ProxyRemove

func ProxyRemove(service string) []string

ProxyRemove builds `kamal-proxy remove <service>` argv.

func ProxyResume

func ProxyResume(service string) []string

ProxyResume builds `kamal-proxy resume <service>` argv.

func ProxyRun

func ProxyRun(p config.Proxy) []string

ProxyRun builds argv to boot the kamal-proxy container on a server.

func ProxyStop

func ProxyStop(service, message string) []string

ProxyStop builds `kamal-proxy stop` argv (maintenance mode).

func PsFilter

func PsFilter(project, service string, all bool, format string) []string

PsFilter builds `docker ps` argv filtered on ferry labels. Empty service or preview matches any; preview "-" filters to non-preview containers.

func Run

func Run(svc types.ServiceConfig, image string, o RunOpts) []string

Run builds `docker run` argv for a compose service. Compose provides command, entrypoint, volumes, healthcheck, labels, restart; ferry injects name, network, labels, env-file and restart default unless-stopped.

func ShellQuote

func ShellQuote(s string) string

ShellQuote makes a string safe for POSIX shell embedding (build-arg values can contain anything).

Types

type ProxyDeployOpts

type ProxyDeployOpts struct {
	Service       string // proxy service name (web, or web-<sha> for previews)
	Target        string // <container>:<port>
	Hosts         []string
	Health        config.Health
	DeployTimeout string
	DrainTimeout  string
	Passthrough   map[string]string // advanced kamal-proxy deploy flags
}

ProxyDeployOpts parameterizes a kamal-proxy target registration.

type RunOpts

type RunOpts struct {
	Name          string // container name (<service>-<version>)
	Project       string // ferry project name (label namespace)
	VolumeProject string // named-volume namespace; defaults to Project. Preview
	//                      isolate services get <project>-<sha> = fresh volumes.
	Service      string // ferry service name
	Version      string // git SHA
	Preview      string // preview SHA, empty for regular deploys
	Network      string // network to start on
	EnvFile      string // local merged env file (delivered via API, not argv)
	Detach       bool
	Rm           bool   // one-shot jobs
	PublishPorts bool   // publish compose ports: entries (unproxied services)
	ConfigHash   string // stateful services: digest of the creation config
}

RunOpts parameterizes a container start beyond what compose expresses.

Jump to

Keyboard shortcuts

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