docker

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Overview

internal/docker/client.go

internal/docker/compose.go

internal/docker/container.go

internal/docker/container_manager_ext.go

internal/docker/image.go

internal/docker/manager.go

internal/docker/network.go

internal/docker/service_info.go

internal/docker/service_manager.go

internal/docker/service_starters.go

internal/docker/types.go

internal/docker/utils.go

internal/docker/volume.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDockerInstallInstructions

func GetDockerInstallInstructions() string

GetDockerInstallInstructions returns platform-specific Docker installation instructions

func PrintServiceStartupInfo

func PrintServiceStartupInfo(serviceName string, port int)

PrintServiceStartupInfo displays detailed service information after startup

Types

type AIServiceStarter

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

AIServiceStarter handles AI service startup

func (*AIServiceStarter) PrintServiceInfo

func (s *AIServiceStarter) PrintServiceInfo()

PrintServiceInfo prints service information including embedding support

func (*AIServiceStarter) Start

func (s *AIServiceStarter) Start() error

Start starts the AI service with proper volume mounting

type CacheServiceStarter

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

CacheServiceStarter handles cache service startup

func (*CacheServiceStarter) Start

func (s *CacheServiceStarter) Start() error

Start starts the cache service

type Client

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

Client wraps the Docker client with LocalCloud-specific functionality

func NewClient

func NewClient(ctx context.Context) (*Client, error)

NewClient creates a new Docker client

func (*Client) CheckDockerVersion

func (c *Client) CheckDockerVersion() error

CheckDockerVersion ensures Docker version is compatible

func (*Client) Close

func (c *Client) Close() error

Close closes the Docker client connection

func (*Client) ContainerWait

func (c *Client) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)

ContainerWait waits for a container to reach a certain condition

func (*Client) GetDockerClient

func (c *Client) GetDockerClient() *client.Client

func (*Client) GetDockerInfo

func (c *Client) GetDockerInfo() (types.Info, error)

GetDockerInfo returns Docker system information

func (*Client) IsDockerRunning

func (c *Client) IsDockerRunning() bool

IsDockerRunning checks if Docker daemon is accessible

func (*Client) NewContainerManager

func (c *Client) NewContainerManager() ContainerManager

NewContainerManager creates a new container manager

func (*Client) NewImageManager

func (c *Client) NewImageManager() ImageManager

NewImageManager creates a new image manager

func (*Client) NewNetworkManager

func (c *Client) NewNetworkManager() NetworkManager

NewNetworkManager creates a new network manager

func (*Client) NewVolumeManager

func (c *Client) NewVolumeManager() VolumeManager

NewVolumeManager creates a new volume manager

func (*Client) StreamLogs

func (c *Client) StreamLogs(containerID string, follow bool, since string, tail string, writer io.Writer) error

StreamLogs streams container logs

type ComposeDeploy

type ComposeDeploy struct {
	Resources ComposeResources `yaml:"resources"`
}

ComposeDeploy represents deployment configuration

type ComposeFile

type ComposeFile struct {
	Version  string                    `yaml:"version"`
	Services map[string]ComposeService `yaml:"services"`
	Networks map[string]ComposeNetwork `yaml:"networks,omitempty"`
	Volumes  map[string]ComposeVolume  `yaml:"volumes,omitempty"`
}

ComposeFile represents a Docker Compose file structure

type ComposeGenerator

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

ComposeGenerator generates Docker Compose files from LocalCloud config

func NewComposeGenerator

func NewComposeGenerator(cfg *config.Config) *ComposeGenerator

NewComposeGenerator creates a new compose generator

func (*ComposeGenerator) Generate

func (g *ComposeGenerator) Generate() (*ComposeFile, error)

Generate generates a Docker Compose file

func (*ComposeGenerator) GenerateOverride

func (g *ComposeGenerator) GenerateOverride() (*ComposeFile, error)

GenerateOverride generates a docker-compose.override.yml for development

func (*ComposeGenerator) WriteToFile

func (g *ComposeGenerator) WriteToFile(compose *ComposeFile, path string) error

WriteToFile writes the compose file to disk

type ComposeHealthCheck

type ComposeHealthCheck struct {
	Test        []string `yaml:"test"`
	Interval    string   `yaml:"interval"`
	Timeout     string   `yaml:"timeout"`
	Retries     int      `yaml:"retries"`
	StartPeriod string   `yaml:"start_period,omitempty"`
}

ComposeHealthCheck represents health check configuration

type ComposeNetwork

type ComposeNetwork struct {
	Driver string `yaml:"driver,omitempty"`
}

ComposeNetwork represents a network in Docker Compose

type ComposeResourceLimits

type ComposeResourceLimits struct {
	Memory string `yaml:"memory,omitempty"`
	CPUs   string `yaml:"cpus,omitempty"`
}

ComposeResourceLimits represents specific resource limits

type ComposeResources

type ComposeResources struct {
	Limits ComposeResourceLimits `yaml:"limits"`
}

ComposeResources represents resource limits

type ComposeService

type ComposeService struct {
	Image         string              `yaml:"image"`
	ContainerName string              `yaml:"container_name"`
	Environment   map[string]string   `yaml:"environment,omitempty"`
	Ports         []string            `yaml:"ports,omitempty"`
	Volumes       []string            `yaml:"volumes,omitempty"`
	Networks      []string            `yaml:"networks,omitempty"`
	Restart       string              `yaml:"restart,omitempty"`
	DependsOn     []string            `yaml:"depends_on,omitempty"`
	Command       []string            `yaml:"command,omitempty"`
	HealthCheck   *ComposeHealthCheck `yaml:"healthcheck,omitempty"`
	Deploy        *ComposeDeploy      `yaml:"deploy,omitempty"`
}

ComposeService represents a service in Docker Compose

type ComposeVolume

type ComposeVolume struct {
	Driver string `yaml:"driver,omitempty"`
}

ComposeVolume represents a volume in Docker Compose

type ContainerConfig

type ContainerConfig struct {
	Name          string
	Image         string
	Env           map[string]string
	Ports         []PortBinding
	Volumes       []VolumeMount
	Networks      []string
	RestartPolicy string
	Memory        int64 // Memory limit in bytes
	CPUQuota      int64 // CPU quota (100000 = 1 CPU)
	HealthCheck   *HealthCheckConfig
	Labels        map[string]string
	Command       []string
}

ContainerConfig represents container configuration

type ContainerInfo

type ContainerInfo struct {
	ID         string
	Name       string
	Image      string
	Status     string
	State      string
	Health     string
	Ports      map[string]string
	Created    int64
	StartedAt  int64
	Memory     int64
	CPUPercent float64
}

ContainerInfo represents container information

type ContainerManager

type ContainerManager interface {
	Create(config ContainerConfig) (string, error)
	Start(containerID string) error
	Stop(containerID string, timeout int) error
	Remove(containerID string) error
	Logs(containerID string, follow bool) (io.ReadCloser, error)
	Inspect(containerID string) (ContainerInfo, error)
	List(filters map[string]string) ([]ContainerInfo, error)
	Exists(name string) (bool, string, error)
	WaitHealthy(containerID string, timeout time.Duration) error
	Stats(containerID string) (ContainerStats, error)
}

ContainerManager manages Docker containers

type ContainerStats

type ContainerStats struct {
	CPUPercent    float64
	MemoryUsage   uint64
	MemoryLimit   uint64
	MemoryPercent float64
	NetworkRx     uint64
	NetworkTx     uint64
	BlockRead     uint64
	BlockWrite    uint64
}

ContainerStats represents container resource usage statistics

type DatabaseServiceStarter

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

DatabaseServiceStarter handles database service startup

func (*DatabaseServiceStarter) Start

func (s *DatabaseServiceStarter) Start() error

Start starts the database service

type HealthCheckConfig

type HealthCheckConfig struct {
	Test        []string
	Interval    int // seconds
	Timeout     int // seconds
	Retries     int
	StartPeriod int // seconds
}

HealthCheckConfig represents health check configuration

type ImageInfo

type ImageInfo struct {
	ID      string
	Name    string
	Tag     string
	Size    int64
	Created int64
}

ImageInfo represents image information

type ImageManager

type ImageManager interface {
	Pull(image string, progress chan<- PullProgress) error
	Exists(image string) (bool, error)
	Remove(image string) error
	List() ([]ImageInfo, error)
	GetSize(image string) (int64, error)
}

ImageManager manages Docker images

type Manager

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

Manager provides a high-level interface for Docker operations

func NewManager

func NewManager(ctx context.Context, cfg *config.Config) (*Manager, error)

NewManager creates a new Docker manager

func (*Manager) CleanupProject

func (m *Manager) CleanupProject() error

CleanupProject removes all project resources

func (*Manager) Close

func (m *Manager) Close() error

Close closes the Docker client connection

func (*Manager) CreateAndStartContainer

func (m *Manager) CreateAndStartContainer(config ContainerConfig) (string, error)

CreateAndStartContainer creates and starts a new container using existing managers

func (*Manager) ExecInContainer

func (m *Manager) ExecInContainer(containerID string, cmd []string) (string, error)

ExecInContainer executes a command in a running container

func (*Manager) GetClient

func (m *Manager) GetClient() *Client

GetClient returns the Docker client for advanced usage

func (*Manager) GetConfig

func (m *Manager) GetConfig() *config.Config

GetConfig returns the current configuration

func (*Manager) GetContainerLogs

func (m *Manager) GetContainerLogs(containerID string, follow bool, tail string) ([]byte, error)

GetContainerLogs retrieves logs from a container

func (*Manager) GetContainerStatus

func (m *Manager) GetContainerStatus(containerID string) (*ContainerInfo, error)

GetContainerStatus gets the status of a container

func (*Manager) GetServicesStatus

func (m *Manager) GetServicesStatus() ([]ServiceStatus, error)

GetServicesStatus delegates to service manager

func (*Manager) InitializeProject

func (m *Manager) InitializeProject() error

InitializeProject initializes Docker resources for a project

func (*Manager) ListContainersByLabel

func (m *Manager) ListContainersByLabel(labels map[string]string) ([]ContainerInfo, error)

ListContainersByLabel lists containers with specific labels

func (*Manager) StartSelectedServices

func (m *Manager) StartSelectedServices(services []string, progress chan<- ServiceProgress) error

StartSelectedServices starts only the specified services

func (*Manager) StartServices

func (m *Manager) StartServices(progress chan<- ServiceProgress) error

StartServices delegates to service manager

func (*Manager) StartServicesByComponents

func (m *Manager) StartServicesByComponents(components []string, progress chan<- ServiceProgress) error

func (*Manager) StopContainer

func (m *Manager) StopContainer(containerID string, timeout int) error

StopContainer stops a running container

func (*Manager) StopServices

func (m *Manager) StopServices(progress chan<- ServiceProgress) error

StopServices delegates to service manager

func (*Manager) WaitForContainerHealth

func (m *Manager) WaitForContainerHealth(containerID string, timeout time.Duration) error

WaitForContainerHealth waits for a container to become healthy

type MinIOServiceInfo

type MinIOServiceInfo struct {
	Port        int
	ConsolePort int
	AccessKey   string
	SecretKey   string
}

MinIOServiceInfo provides MinIO-specific information

func (*MinIOServiceInfo) PrintInfo

func (m *MinIOServiceInfo) PrintInfo()

PrintInfo displays MinIO service information

type MongoDBServiceStarter added in v0.2.0

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

MongoDBServiceStarter handles MongoDB service startup

func (*MongoDBServiceStarter) Start added in v0.2.0

func (s *MongoDBServiceStarter) Start() error

Start starts the MongoDB service

type NetworkInfo

type NetworkInfo struct {
	ID     string
	Name   string
	Driver string
}

NetworkInfo represents network information

type NetworkManager

type NetworkManager interface {
	Create(name string) (string, error)
	Remove(networkID string) error
	Exists(name string) (bool, string, error)
	List() ([]NetworkInfo, error)
}

NetworkManager manages Docker networks

type OllamaServiceInfo

type OllamaServiceInfo struct {
	Port   int
	Models []string
}

OllamaServiceInfo provides Ollama-specific information

func (*OllamaServiceInfo) PrintInfo

func (o *OllamaServiceInfo) PrintInfo()

PrintInfo displays Ollama service information

type PortBinding

type PortBinding struct {
	ContainerPort string
	HostPort      string
	Protocol      string // tcp or udp
}

PortBinding represents a port binding configuration

type PostgresServiceInfo

type PostgresServiceInfo struct {
	Port     int
	User     string
	Password string
	Database string
}

PostgresServiceInfo provides PostgreSQL-specific information

func (*PostgresServiceInfo) PrintInfo

func (p *PostgresServiceInfo) PrintInfo()

PrintInfo displays PostgreSQL service information

type ProgressDetail

type ProgressDetail struct {
	Current int64
	Total   int64
}

ProgressDetail represents detailed progress information

type PullProgress

type PullProgress struct {
	Status         string
	Progress       string
	ProgressDetail ProgressDetail
	Error          string
}

PullProgress represents image pull progress

type QueueServiceStarter

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

QueueServiceStarter handles queue service startup

func (*QueueServiceStarter) Start

func (s *QueueServiceStarter) Start() error

Start starts the queue service

type RedisServiceInfo

type RedisServiceInfo struct {
	Port int
}

RedisServiceInfo provides Redis-specific information and examples

func (*RedisServiceInfo) PrintInfo

func (r *RedisServiceInfo) PrintInfo()

PrintInfo displays Redis service information with queue examples

type ServiceInfoProvider

type ServiceInfoProvider interface {
	PrintInfo()
}

ServiceInfoProvider provides detailed service information and examples

func GetServiceInfoProvider

func GetServiceInfoProvider(serviceName string, config interface{}) ServiceInfoProvider

GetServiceInfoProvider returns the appropriate service info provider

type ServiceManager

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

ServiceManager handles service-specific operations

func NewServiceManager

func NewServiceManager(m *Manager) *ServiceManager

NewServiceManager creates a new service manager

func (*ServiceManager) GetStatus

func (sm *ServiceManager) GetStatus() ([]ServiceStatus, error)

func (*ServiceManager) StartAll

func (sm *ServiceManager) StartAll(progress chan<- ServiceProgress) error

StartAll starts all configured services

func (*ServiceManager) StartSelectedServices

func (sm *ServiceManager) StartSelectedServices(services []string, progress chan<- ServiceProgress) error

StartSelectedServices starts only the specified services

func (*ServiceManager) StartServicesByComponents

func (sm *ServiceManager) StartServicesByComponents(components []string, progress chan<- ServiceProgress) error

func (*ServiceManager) StopAll

func (sm *ServiceManager) StopAll(progress chan<- ServiceProgress) error

StopAll stops all services

func (*ServiceManager) WaitForService

func (sm *ServiceManager) WaitForService(service string, timeout time.Duration) error

WaitForService waits for a specific service to be ready

type ServiceProgress

type ServiceProgress struct {
	Service string
	Status  string
	Error   string
}

ServiceProgress represents service operation progress

type ServiceStarter

type ServiceStarter interface {
	Start() error
}

ServiceStarter interface for starting individual services

func NewAIServiceStarter

func NewAIServiceStarter(m *Manager) ServiceStarter

NewAIServiceStarter creates a new AI service starter

func NewCacheServiceStarter

func NewCacheServiceStarter(m *Manager) ServiceStarter

NewCacheServiceStarter creates a new cache service starter

func NewDatabaseServiceStarter

func NewDatabaseServiceStarter(m *Manager) ServiceStarter

NewDatabaseServiceStarter creates a new database service starter

func NewMongoDBServiceStarter added in v0.2.0

func NewMongoDBServiceStarter(m *Manager) ServiceStarter

NewMongoDBServiceStarter creates a new MongoDB service starter

func NewQueueServiceStarter

func NewQueueServiceStarter(m *Manager) ServiceStarter

NewQueueServiceStarter creates a new queue service starter

func NewStorageServiceStarter

func NewStorageServiceStarter(m *Manager) ServiceStarter

NewStorageServiceStarter creates a new storage service starter

type ServiceStatus

type ServiceStatus struct {
	Name        string
	Status      string
	Health      string
	Port        string
	CPUPercent  float64
	MemoryUsage uint64
	MemoryLimit uint64
}

ServiceStatus represents the status of a service

type StorageServiceStarter

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

StorageServiceStarter handles storage service startup

func (*StorageServiceStarter) Start

func (s *StorageServiceStarter) Start() error

Start starts the storage service

type VolumeInfo

type VolumeInfo struct {
	Name       string
	Driver     string
	Mountpoint string
	Created    time.Time
	Labels     map[string]string
	Scope      string
	Size       int64
}

VolumeInfo represents volume information

type VolumeManager

type VolumeManager interface {
	Create(name string, labels map[string]string) error
	Remove(name string) error
	Exists(name string) (bool, error)
	List(filter map[string]string) ([]VolumeInfo, error)
	Backup(volumeName string, targetPath string) error
	Restore(volumeName string, sourcePath string) error
}

VolumeManager manages Docker volumes

type VolumeMount

type VolumeMount struct {
	Source   string
	Target   string
	Type     string // "bind" or "volume"
	ReadOnly bool
}

VolumeMount represents a volume mount configuration

Jump to

Keyboard shortcuts

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