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
- func Build(build *types.BuildConfig, image string) []string
- func BuildScript(build *types.BuildConfig, image, ctxDir string) string
- func ConfigHash(svc types.ServiceConfig, image string, o RunOpts, env []byte) string
- func ContextCreate(name string, s *config.Server) []string
- func Labels(svc types.ServiceConfig, o RunOpts) []string
- func ProxyDeploy(o ProxyDeployOpts) []string
- func ProxyRemove(service string) []string
- func ProxyResume(service string) []string
- func ProxyRun(p config.Proxy) []string
- func ProxyStop(service, message string) []string
- func PsFilter(project, service string, all bool, format string) []string
- func Run(svc types.ServiceConfig, image string, o RunOpts) []string
- func ShellQuote(s string) string
- type ProxyDeployOpts
- type RunOpts
Constants ¶
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.
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 ¶
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 ¶
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 ¶
ProxyRemove builds `kamal-proxy remove <service>` argv.
func ProxyResume ¶
ProxyResume builds `kamal-proxy resume <service>` argv.
func PsFilter ¶
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 ¶
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.