container

package
v0.0.0-...-cebc4e0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentOptions

type AgentOptions struct {
	Name               string            // container name: forge-agent-<project-id>-<session-id>
	Image              string            // agent image
	NetworkName        string            // Docker network to attach to
	ProjectDir         string            // host path to project (mounted at /work)
	SessionDir         string            // host path to session storage
	ClaudeDir          string            // host path to ~/.claude/
	ConfigDir          string            // host path to ~/.config/claude-forge/
	HomeDir            string            // host home dir for CLAUDE.md paths
	Env                map[string]string // environment variables
	Privileged         bool
	Interactive        bool                // allocate TTY and stdin (for docker attach)
	Cmd                []string            // claude args: --dangerously-skip-permissions, --worktree, etc.
	UID                int                 // host user UID (for file ownership mapping)
	GID                int                 // host user GID (for file ownership mapping)
	PluginsDir         string              // host path to forge plugins dir (mounted rw at ~/.claude/plugins)
	CacheDirs          []CacheDir          // host dependency cache directories to mount (rw)
	ExtraMounts        []CacheDir          // additional user-specified bind mounts (rw)
	ResumeWorktreeName string              // worktree name when resuming a worktree session
	ExtraNetworks      []NetworkAttachment // additional networks to connect before starting
}

AgentOptions holds configuration for starting an agent container.

type CacheDir

type CacheDir struct {
	Source string // host path
	Target string // container path
}

CacheDir represents a host dependency cache directory to mount into the container.

type Client

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

Client provides Docker operations for claude-forge.

func NewClient

func NewClient() (*Client, error)

NewClient creates a new Docker client using environment configuration.

func (*Client) Close

func (c *Client) Close() error

Close closes the Docker client connection.

func (*Client) ConnectNetwork

func (c *Client) ConnectNetwork(ctx context.Context, networkName, containerName string, aliases []string) error

ConnectNetwork connects a container to a Docker network with optional aliases.

func (*Client) ContainerLogs

func (c *Client) ContainerLogs(ctx context.Context, containerID string) (string, error)

ContainerLogs returns the stdout/stderr logs from a container.

func (*Client) CreateNetwork

func (c *Client) CreateNetwork(ctx context.Context, name string) (string, error)

CreateNetwork creates a Docker network with the given name.

func (*Client) EnsureSharedNetwork

func (c *Client) EnsureSharedNetwork(ctx context.Context, name string) (string, error)

EnsureSharedNetwork creates a shared Docker network if it doesn't already exist. Returns the network ID.

func (*Client) ImageExists

func (c *Client) ImageExists(ctx context.Context, imageName string) (bool, error)

ImageExists checks if a Docker image exists locally.

func (*Client) IsContainerRunning

func (c *Client) IsContainerRunning(ctx context.Context, name string) (bool, error)

IsContainerRunning checks if a container with the given name exists and is running. Returns false (no error) if the container doesn't exist.

func (*Client) ListForgeContainers

func (c *Client) ListForgeContainers(ctx context.Context) ([]ContainerInfo, error)

ListForgeContainers lists containers with names matching "forge-agent-*" or "forge-gateway-*".

func (*Client) PullImage

func (c *Client) PullImage(ctx context.Context, imageName string) error

PullImage pulls a Docker image.

func (*Client) RemoveContainer

func (c *Client) RemoveContainer(ctx context.Context, name string) error

RemoveContainer removes a container by name.

func (*Client) RemoveNetwork

func (c *Client) RemoveNetwork(ctx context.Context, name string) error

RemoveNetwork removes a Docker network by name.

func (*Client) StartAgent

func (c *Client) StartAgent(ctx context.Context, opts AgentOptions) (string, error)

StartAgent creates and starts an agent container.

func (*Client) StartGateway

func (c *Client) StartGateway(ctx context.Context, opts GatewayOptions) (string, error)

StartGateway creates and starts a gateway container.

func (*Client) StartGitHubMCP

func (c *Client) StartGitHubMCP(ctx context.Context, opts GitHubMCPOptions) (string, error)

StartGitHubMCP creates and starts a GitHub MCP sidecar container.

func (*Client) StartSharedService

func (c *Client) StartSharedService(ctx context.Context, opts SharedServiceOptions) (string, error)

StartSharedService creates and starts a shared singleton service container.

func (*Client) StopContainer

func (c *Client) StopContainer(ctx context.Context, name string) error

StopContainer stops a container by name.

func (*Client) WaitForReady

func (c *Client) WaitForReady(ctx context.Context, containerID string, timeout time.Duration) error

WaitForReady polls the container state until it is running or exits. After the container first appears running, it re-checks after a short stabilization delay to catch processes that crash immediately on startup. Returns an error if the container exits before the timeout.

type ContainerInfo

type ContainerInfo struct {
	Name    string
	ID      string
	Image   string
	Status  string
	Created time.Time
}

ContainerInfo holds information about a running container.

type ContainerManager

type ContainerManager interface {
	CreateNetwork(ctx context.Context, name string) (string, error)
	RemoveNetwork(ctx context.Context, name string) error
	EnsureSharedNetwork(ctx context.Context, name string) (string, error)
	ConnectNetwork(ctx context.Context, networkName, containerName string, aliases []string) error
	StartAgent(ctx context.Context, opts AgentOptions) (string, error)
	StartGateway(ctx context.Context, opts GatewayOptions) (string, error)
	StartGitHubMCP(ctx context.Context, opts GitHubMCPOptions) (string, error)
	StartSharedService(ctx context.Context, opts SharedServiceOptions) (string, error)
	IsContainerRunning(ctx context.Context, name string) (bool, error)
	WaitForReady(ctx context.Context, containerID string, timeout time.Duration) error
	StopContainer(ctx context.Context, name string) error
	RemoveContainer(ctx context.Context, name string) error
	ListForgeContainers(ctx context.Context) ([]ContainerInfo, error)
	PullImage(ctx context.Context, image string) error
	ImageExists(ctx context.Context, image string) (bool, error)
	ContainerLogs(ctx context.Context, containerID string) (string, error)
	Close() error
}

ContainerManager abstracts container operations for the orchestrator.

type DockerAPI

type DockerAPI interface {
	ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.CreateResponse, error)
	ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error
	ContainerStop(ctx context.Context, containerID string, options container.StopOptions) error
	ContainerRemove(ctx context.Context, containerID string, options container.RemoveOptions) error
	ContainerList(ctx context.Context, options container.ListOptions) ([]container.Summary, error)
	ContainerInspect(ctx context.Context, containerID string) (container.InspectResponse, error)
	ContainerLogs(ctx context.Context, containerID string, options container.LogsOptions) (io.ReadCloser, error)
	NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
	NetworkRemove(ctx context.Context, networkID string) error
	NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error
	NetworkList(ctx context.Context, options network.ListOptions) ([]network.Inspect, error)
	ImagePull(ctx context.Context, refStr string, options image.PullOptions) (io.ReadCloser, error)
	ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
	Close() error
}

DockerAPI abstracts the Docker client methods used by the forge client.

type GatewayOptions

type GatewayOptions struct {
	Name        string // container name: forge-gateway-<project-id>-<session-id>
	Image       string
	NetworkName string
	SSHDir      string // host ~/.ssh/ (ro)
	GHConfigDir string // host ~/.config/gh/ (ro)
	Owner       string // allowed repo owner
	Repo        string // allowed repo name
	Env         map[string]string
}

GatewayOptions holds configuration for starting a gateway container.

type GitHubMCPOptions

type GitHubMCPOptions struct {
	Name        string            // container name: forge-github-mcp-<project-id>-<session-id>
	Image       string            // github-mcp image
	NetworkName string            // Docker network to attach to
	Owner       string            // allowed repo owner
	Repo        string            // allowed repo name
	Env         map[string]string // environment variables (GITHUB_TOKEN)
}

GitHubMCPOptions holds configuration for starting a GitHub MCP sidecar container.

type NetworkAttachment

type NetworkAttachment struct {
	NetworkName string   // Docker network name
	Aliases     []string // optional DNS aliases within the network
}

NetworkAttachment describes a network to connect to a container before starting it.

type SharedServiceOptions

type SharedServiceOptions struct {
	Name        string            // container name, e.g. "forge-k8s-mcp"
	Image       string            // Docker image
	NetworkName string            // shared network name
	Alias       string            // network alias, e.g. "k8s-mcp"
	Env         map[string]string // environment variables
	Mounts      []mount.Mount     // bind mounts
	Cmd         []string          // container command
}

SharedServiceOptions holds configuration for starting a shared singleton service container.

Jump to

Keyboard shortcuts

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