docker

package
v0.0.0-...-4587172 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Overview

Package docker implements executor.Executor by launching agent workloads as Docker containers, for the open, single-tenant self-hosted deployment. It is the single-tenant counterpart to github.com/dangtrivan15/choruskube/worker/executor/k8s: same contract, no per-org namespace isolation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Host is the Docker daemon socket (e.g. "unix:///var/run/docker.sock"). Empty uses the
	// client library's own environment-based default.
	Host string
	// Network is the Docker network agent containers and DinD sidecars attach to. Empty falls
	// back to "choruskube".
	Network string
	// StagingDir is the base directory under which per-execution config/credential staging
	// dirs are created. Blank falls back to the OS temp dir.
	//
	// In Docker-out-of-Docker deployments the Worker itself runs in a container but talks to
	// the host daemon over a mounted socket, so a bind source path must resolve to the same
	// bytes on the host as it does here — this dir must be mounted at an identical path on
	// both sides.
	StagingDir string
	// DindReadyTimeout bounds how long Execute waits for a DinD sidecar's healthcheck to pass
	// before failing the execution. Zero defaults to 30s.
	DindReadyTimeout time.Duration
	// DindImage is the image started as the DinD sidecar. Empty falls back to the stock
	// "docker:29-dind".
	DindImage string
}

Config configures a DockerExecutor.

type DockerExecutor

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

DockerExecutor implements executor.Executor by launching agent workloads as Docker containers on a single Docker daemon.

func New

func New(cfg Config) (*DockerExecutor, error)

New returns a DockerExecutor connected to the Docker daemon described by cfg.

func (*DockerExecutor) Cleanup

func (d *DockerExecutor) Cleanup(ctx context.Context, executionID uuid.UUID) error

Cleanup removes all Docker resources for executionID: the agent container, its staging directory, and — if this execution had DinD enabled — the DinD sidecar and its data volume. It is idempotent: a missing container is not an error, since the caller may retry after a partial cleanup or call Cleanup for an execution that never created any resources.

func (*DockerExecutor) Execute

Execute launches params as a new Docker container: it stages config.json to a per-execution directory reachable by the Docker daemon, optionally starts a DinD sidecar and a registry auth config, then creates and starts the agent container.

func (*DockerExecutor) GetLogs

func (d *DockerExecutor) GetLogs(ctx context.Context, executionID uuid.UUID, tailLines int) (string, error)

GetLogs returns up to the last tailLines lines of executionID's container output (stdout and stderr interleaved), capped at 64KB.

func (*DockerExecutor) HealthCheck

func (d *DockerExecutor) HealthCheck(ctx context.Context) error

HealthCheck verifies the Docker daemon is reachable.

func (*DockerExecutor) ResolveJobSecretHash

func (d *DockerExecutor) ResolveJobSecretHash(ctx context.Context, _, executionID uuid.UUID) (string, error)

ResolveJobSecretHash reads JOB_SECRET back from executionID's container environment and returns its SHA-256 hash. Used to recover the hash cache after a Worker restart. A single Docker host has no namespaces, so the runID is ignored.

func (*DockerExecutor) Terminate

func (d *DockerExecutor) Terminate(ctx context.Context, executionID uuid.UUID) error

Terminate stops executionID's container gracefully (SIGTERM, 30s grace before SIGKILL). Idempotent: an already-stopped or already-gone container is not an error.

Jump to

Keyboard shortcuts

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