dockerrun

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelCodeflyOwner     = "codefly.owner"     // always "true"
	LabelCodeflySession   = "codefly.session"   // PID of the spawning CLI
	LabelCodeflyName      = "codefly.name"      // container's logical name
	LabelCodeflyEphemeral = "codefly.ephemeral" // "true" for SDK/test (--cli-server) containers
)

Container labels used by the startup sweep to identify codefly-owned containers and their spawning CLI. These are set on every container created via DockerEnvironment and consumed by ReapStaleContainers.

Variables

This section is empty.

Functions

func ContainerName

func ContainerName(name string) string

func DockerEngineRunning

func DockerEngineRunning(ctx context.Context) bool

func EphemeralContainers

func EphemeralContainers() bool

EphemeralContainers reports whether this process spawns ephemeral containers.

func Forward

func Forward(ctx context.Context, reader io.Reader, writer io.Writer)

func GetImageID

func GetImageID(im *resources.DockerImage) (string, error)

func GetImageIfNotPresent

func GetImageIfNotPresent(ctx context.Context, c *client.Client, imag *resources.DockerImage, out io.Writer) error

func ImageExists

func ImageExists(ctx context.Context, c *client.Client, imag *resources.DockerImage) (bool, error)

func PrintDownloadPercentage

func PrintDownloadPercentage(reader io.ReadCloser, out io.Writer)

func ReapStaleContainers

func ReapStaleContainers(ctx context.Context) error

func SetEphemeralContainers

func SetEphemeralContainers(v bool)

SetEphemeralContainers marks dependency containers spawned by this process as ephemeral so the startup sweep reaps them even while running. The CLI calls this when it parses --cli-server.

Types

type DockerContainerInstance

type DockerContainerInstance struct {
	ID string
}

type DockerEnvironment

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

func NewDockerEnvironment

func NewDockerEnvironment(ctx context.Context, image *resources.DockerImage, dir, name string) (*DockerEnvironment, error)

NewDockerEnvironment creates a new docker environment.

If GetImageIfNotPresent fails, the docker client is closed before returning the error so the caller doesn't have to know about the half-constructed env (and isn't expected to call Shutdown on a nil return). Same defensive close in NewDockerHeadlessEnvironment.

func NewDockerHeadlessEnvironment

func NewDockerHeadlessEnvironment(ctx context.Context, image *resources.DockerImage, name string) (*DockerEnvironment, error)

NewDockerHeadlessEnvironment creates a new docker runner

func (*DockerEnvironment) ContainerDeleted

func (docker *DockerEnvironment) ContainerDeleted() (bool, error)

ContainerDeleted checks if the container with ID is gone

func (*DockerEnvironment) ContainerID

func (docker *DockerEnvironment) ContainerID() (string, error)

func (*DockerEnvironment) GetContainer

func (docker *DockerEnvironment) GetContainer(ctx context.Context) error

func (*DockerEnvironment) GetImageIfNotPresent

func (docker *DockerEnvironment) GetImageIfNotPresent(ctx context.Context, imag *resources.DockerImage) error

func (*DockerEnvironment) GetLogs

func (docker *DockerEnvironment) GetLogs(ctx context.Context) error

func (*DockerEnvironment) ImageExists

func (docker *DockerEnvironment) ImageExists(ctx context.Context, imag *resources.DockerImage) (bool, error)

func (*DockerEnvironment) Init

func (docker *DockerEnvironment) Init(ctx context.Context) error

func (*DockerEnvironment) IsContainerPresent

func (docker *DockerEnvironment) IsContainerPresent(ctx context.Context) (bool, error)

func (*DockerEnvironment) NewProcess

func (docker *DockerEnvironment) NewProcess(bin string, args ...string) (base.Proc, error)

func (*DockerEnvironment) PortMappings

func (docker *DockerEnvironment) PortMappings() []*DockerPortMapping

func (*DockerEnvironment) Shutdown

func (docker *DockerEnvironment) Shutdown(ctx context.Context) error

func (*DockerEnvironment) Stop

func (docker *DockerEnvironment) Stop(ctx context.Context) error

func (*DockerEnvironment) TailLogs

func (docker *DockerEnvironment) TailLogs(ctx context.Context, lines int) string

TailLogs returns the last `lines` lines of combined stdout+stderr for the container. Used by agent runtimes to enrich startup-failure errors with the actual container output (otherwise the user only sees a generic "not ready" timeout). Returns "" on any error so callers can safely append without conditional logic.

func (*DockerEnvironment) WithBinary

func (docker *DockerEnvironment) WithBinary(bin string) error

func (*DockerEnvironment) WithCommand

func (docker *DockerEnvironment) WithCommand(cmd ...string)

func (*DockerEnvironment) WithDir

func (docker *DockerEnvironment) WithDir(dir string)

func (*DockerEnvironment) WithEnvironmentVariables

func (docker *DockerEnvironment) WithEnvironmentVariables(ctx context.Context, envs ...*resources.EnvironmentVariable)

func (*DockerEnvironment) WithMount

func (docker *DockerEnvironment) WithMount(sourceDir string, targetDir string)

func (*DockerEnvironment) WithOutput

func (docker *DockerEnvironment) WithOutput(w io.Writer)

func (*DockerEnvironment) WithPause

func (docker *DockerEnvironment) WithPause()

func (*DockerEnvironment) WithPort

func (docker *DockerEnvironment) WithPort(ctx context.Context, port uint16)

func (*DockerEnvironment) WithPortMapping

func (docker *DockerEnvironment) WithPortMapping(ctx context.Context, local uint16, container uint16)

func (*DockerEnvironment) WithWorkDir

func (docker *DockerEnvironment) WithWorkDir(dir string)

type DockerPortMapping

type DockerPortMapping struct {
	Host      uint16
	Container uint16
}

type DockerProc

type DockerProc struct {
	ID string
	// contains filtered or unexported fields
}

func (*DockerProc) FindPid

func (proc *DockerProc) FindPid(ctx context.Context) (int, error)

FindPid locates the PID of the matching child process inside the container by scanning /proc. /proc is guaranteed on every Linux container; `ps` is not (debian-slim images ship without procps, Alpine busybox has a different flag set). Output format is one line per PID:

<pid>\t<cmdline-space-separated>

where cmdline is the full argv reconstructed from /proc/<pid>/cmdline (NUL-separated in the kernel — we convert NUL→space for splitting).

func (*DockerProc) IsRunning

func (proc *DockerProc) IsRunning(ctx context.Context) (bool, error)

func (*DockerProc) Match

func (proc *DockerProc) Match(cmd []string) bool

func (*DockerProc) Run

func (proc *DockerProc) Run(ctx context.Context) error

func (*DockerProc) Start

func (proc *DockerProc) Start(ctx context.Context) error

func (*DockerProc) StdinPipe

func (proc *DockerProc) StdinPipe() (io.WriteCloser, error)

func (*DockerProc) StdoutPipe

func (proc *DockerProc) StdoutPipe() (io.ReadCloser, error)

func (*DockerProc) Stop

func (proc *DockerProc) Stop(ctx context.Context) error

func (*DockerProc) Wait

func (proc *DockerProc) Wait(ctx context.Context) error

Wait blocks until the container process exits or ctx is cancelled. Polls IsRunning since Docker doesn't expose a clean blocking-wait here.

func (*DockerProc) WaitOn

func (proc *DockerProc) WaitOn(bin string)

func (*DockerProc) WithDir

func (proc *DockerProc) WithDir(dir string)

func (*DockerProc) WithEnvironmentVariables

func (proc *DockerProc) WithEnvironmentVariables(ctx context.Context, envs ...*resources.EnvironmentVariable)

func (*DockerProc) WithEnvironmentVariablesAppend

func (proc *DockerProc) WithEnvironmentVariablesAppend(ctx context.Context, added *resources.EnvironmentVariable, sep string)

func (*DockerProc) WithOutput

func (proc *DockerProc) WithOutput(output io.Writer)

type DockerPullResponse

type DockerPullResponse struct {
	ID             string         `json:"id"`
	Status         string         `json:"status"`
	ProgressDetail ProgressDetail `json:"progressDetail"`
}

type ProgressDetail

type ProgressDetail struct {
	Current int `json:"current"`
	Total   int `json:"total"`
}

Jump to

Keyboard shortcuts

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