Documentation
¶
Index ¶
- Constants
- Variables
- func CleanupWorkspace(ctx context.Context, cli *client.Client, containerID, workspacePath string) error
- func ConnectNetwork(ctx context.Context, cli *client.Client, networkID, containerID string) error
- func CopyContainerToHost(ctx context.Context, cli *client.Client, ...) error
- func CopyFromContainer(ctx context.Context, cli *client.Client, ...) error
- func CopyHostToContainer(ctx context.Context, cli *client.Client, ...) error
- func CopyToContainer(ctx context.Context, cli *client.Client, containerID, dstPath string, ...) error
- func CopyWorkspace(ctx context.Context, cli *client.Client, config CopyConfig) error
- func CreateContainer(ctx context.Context, cli *client.Client, imageName, workingDir string, ...) (string, error)
- func CreateDockerClient() (*client.Client, error)
- func CreateNetwork(ctx context.Context, cli *client.Client, networkName string) (string, error)
- func CreateServiceContainer(ctx context.Context, cli *client.Client, networkName, serviceName string, ...) (string, string, error)
- func DetectDockerSocket() string
- func EnsureImage(ctx context.Context, cli *client.Client, imageName string, offline bool, ...) error
- func EnsureWorkspaceDir(ctx context.Context, cli *client.Client, containerID, workspacePath string) error
- func InspectContainer(ctx context.Context, cli *client.Client, containerID string) (container.InspectResponse, error)
- func IsLocalDockerHost(host string) bool
- func IsValidPlatform(s string) bool
- func ParseDockerHost(host string) (protocol, address string)
- func ParseHealthConfig(optionsStr string) *container.HealthConfig
- func ParsePlatform(s string) (os, arch string, err error)
- func ParsePorts(ports []any) (nat.PortSet, nat.PortMap, string, error)
- func RemoveContainer(ctx context.Context, cli *client.Client, containerID string) error
- func RemoveNetwork(ctx context.Context, cli *client.Client, networkID string) error
- func ResolveImage(runsOn string) (string, error)
- func StartContainer(ctx context.Context, cli *client.Client, containerID string) error
- func StopContainer(ctx context.Context, cli *client.Client, containerID string, timeoutSec int) error
- func TarDirectory(srcPath string, excludePatterns []string) (io.Reader, error)
- func WaitContainer(ctx context.Context, cli *client.Client, containerID string) error
- func WaitForServiceReady(ctx context.Context, cli *client.Client, containerID string, hostPort string, ...) error
- type CopyConfig
- type ExecResult
- type Platform
- type ServiceConfig
- type VolumeManager
- func (vm *VolumeManager) CleanupVolumes(ctx context.Context, labelKey, labelValue string) error
- func (vm *VolumeManager) EnsureGacilsVolume(ctx context.Context) error
- func (vm *VolumeManager) EnsureVolume(ctx context.Context, name string, labels map[string]string) error
- func (vm *VolumeManager) RemoveVolume(ctx context.Context, name string, force bool) error
- func (vm *VolumeManager) VolumeExists(ctx context.Context, name string) (bool, error)
Constants ¶
const DefaultDockerSocket = "/var/run/docker.sock"
DefaultDockerSocket is the default Docker socket path.
const GacilsVolumeName = "gacils-tmp"
GacilsVolumeName returns the standard gacils volume name.
Variables ¶
var DefaultExcludePatterns = []string{
".git",
".gacils",
".gacils-local",
"node_modules",
"__pycache__",
".venv",
"venv",
"dist",
"build",
"target",
"coverage.out",
"*.log",
}
DefaultExcludePatterns are the default patterns to exclude when creating a tar archive.
var KnownPlatforms = []Platform{ PlatformLinuxAMD64, PlatformLinuxARM64, PlatformLinuxARMv7, PlatformLinux386, PlatformLinuxPPC64le, PlatformLinuxS390x, }
KnownPlatforms is the list of supported platforms.
var RunnerLabelToImage = map[string]string{
"ubuntu-latest": "ubuntu:24.04",
"ubuntu-24.04": "ubuntu:24.04",
"ubuntu-22.04": "ubuntu:22.04",
}
RunnerLabelToImage maps GitHub runner labels to Docker images.
Functions ¶
func CleanupWorkspace ¶
func CleanupWorkspace(ctx context.Context, cli *client.Client, containerID, workspacePath string) error
CleanupWorkspace removes temporary workspace files from container.
func ConnectNetwork ¶
ConnectNetwork connects a container to a Docker network.
func CopyContainerToHost ¶
func CopyContainerToHost(ctx context.Context, cli *client.Client, containerID, srcContainerPath, dstHostPath string) error
CopyContainerToHost copies files or directories from container path to host destination path.
func CopyFromContainer ¶
func CopyFromContainer(ctx context.Context, cli *client.Client, containerID, srcPath, dstHostPath string) error
CopyFromContainer copies files from container to host using tar stream.
func CopyHostToContainer ¶
func CopyHostToContainer(ctx context.Context, cli *client.Client, containerID, srcHostPath, dstContainerPath string) error
CopyHostToContainer copies files from host directory or file to container path.
func CopyToContainer ¶
func CopyToContainer(ctx context.Context, cli *client.Client, containerID, dstPath string, tarReader io.Reader) error
CopyToContainer copies files from host to container using tar stream.
func CopyWorkspace ¶
CopyWorkspace copies the workspace to a running container.
func CreateContainer ¶
func CreateContainer(ctx context.Context, cli *client.Client, imageName, workingDir string, githubEnvPath, githubPathPath string, githubContext, runnerContext map[string]string) (string, error)
CreateContainer creates a new Docker container for running a job.
func CreateDockerClient ¶ added in v1.3.1
CreateDockerClient creates a Docker client that respects environment variables and automatically detects the correct socket path (Linux native, WSL2, etc.)
func CreateNetwork ¶
CreateNetwork creates a Docker bridge network with the specified name.
func CreateServiceContainer ¶
func CreateServiceContainer(ctx context.Context, cli *client.Client, networkName, serviceName string, serviceConfig ServiceConfig) (string, string, error)
CreateServiceContainer creates a service container connected to the specified network.
func DetectDockerSocket ¶
func DetectDockerSocket() string
DetectDockerSocket attempts to find the Docker socket path. Checks: DOCKER_HOST env, default socket, Docker Desktop paths.
func EnsureImage ¶
func EnsureImage(ctx context.Context, cli *client.Client, imageName string, offline bool, platform string) error
EnsureImage checks if an image exists locally, and pulls it if not (unless offline mode).
func EnsureWorkspaceDir ¶
func EnsureWorkspaceDir(ctx context.Context, cli *client.Client, containerID, workspacePath string) error
EnsureWorkspaceDir ensures the workspace directory exists in the container.
func InspectContainer ¶ added in v1.4.0
func InspectContainer(ctx context.Context, cli *client.Client, containerID string) (container.InspectResponse, error)
InspectContainer inspects a container and returns its details.
func IsLocalDockerHost ¶
IsLocalDockerHost checks if the Docker host is local (unix socket).
func IsValidPlatform ¶
IsValidPlatform checks if a platform string is valid and known.
func ParseDockerHost ¶
ParseDockerHost parses a Docker host string into protocol and address.
func ParseHealthConfig ¶
func ParseHealthConfig(optionsStr string) *container.HealthConfig
ParseHealthConfig parses health check options from the options string.
func ParsePlatform ¶
ParsePlatform validates and parses a platform string. Formats supported:
- "" (empty) → ("", "", nil) — use host default
- "os/arch" (2 parts) → (os, arch, nil)
- "os/arch/variant" (3 parts) → (os, "arch/variant", nil)
func ParsePorts ¶
ParsePorts parses port mapping options into nat.PortSet and nat.PortMap.
func RemoveContainer ¶
RemoveContainer removes a Docker container.
func RemoveNetwork ¶
RemoveNetwork removes a Docker network by ID.
func ResolveImage ¶
ResolveImage resolves a runs-on label to a Docker image.
func StartContainer ¶
StartContainer starts a Docker container.
func StopContainer ¶ added in v1.4.0
func StopContainer(ctx context.Context, cli *client.Client, containerID string, timeoutSec int) error
StopContainer stops a running container gracefully. This is used for ephemeral containers that keep running (e.g., tail -f /dev/null) to keep the container alive for exec commands.
func TarDirectory ¶
TarDirectory creates a tar stream of a directory for docker copy operations.
func WaitContainer ¶ added in v1.4.0
WaitContainer waits for a container to finish and returns its exit code.
Types ¶
type CopyConfig ¶
type CopyConfig struct {
SourcePath string
TargetPath string
ContainerID string
ExcludePatterns []string
FollowSymlinks bool
}
CopyConfig holds configuration for copying workspace to container.
type ExecResult ¶
ExecResult represents the result of executing a command in a container.
type Platform ¶
type Platform string
Platform represents a normalized Docker platform.
const ( // PlatformLinuxAMD64 represents linux/amd64. PlatformLinuxAMD64 Platform = "linux/amd64" // PlatformLinuxARM64 represents linux/arm64. PlatformLinuxARM64 Platform = "linux/arm64" // PlatformLinuxARMv7 represents linux/arm/v7. PlatformLinuxARMv7 Platform = "linux/arm/v7" // PlatformLinux386 represents linux/386. PlatformLinux386 Platform = "linux/386" // PlatformLinuxPPC64le represents linux/ppc64le. PlatformLinuxPPC64le Platform = "linux/ppc64le" // PlatformLinuxS390x represents linux/s390x. PlatformLinuxS390x Platform = "linux/s390x" )
func NormalizePlatform ¶
NormalizePlatform normalizes a platform string to a standard format. Accepts formats like: "linux/amd64", "amd64", "x86_64", "arm64", "aarch64"
type ServiceConfig ¶
type ServiceConfig struct {
Name string
Image string
Env map[string]any
Ports []any
Options string
}
ServiceConfig represents container configuration for a service.
type VolumeManager ¶
type VolumeManager struct {
// contains filtered or unexported fields
}
VolumeManager manages Docker volumes for gacils.
func NewVolumeManager ¶
func NewVolumeManager(cli *client.Client) *VolumeManager
NewVolumeManager creates a new volume manager.
func (*VolumeManager) CleanupVolumes ¶
func (vm *VolumeManager) CleanupVolumes(ctx context.Context, labelKey, labelValue string) error
CleanupVolumes removes volumes with a specific label.
func (*VolumeManager) EnsureGacilsVolume ¶
func (vm *VolumeManager) EnsureGacilsVolume(ctx context.Context) error
EnsureGacilsVolume ensures the gacils temporary volume exists.
func (*VolumeManager) EnsureVolume ¶
func (vm *VolumeManager) EnsureVolume(ctx context.Context, name string, labels map[string]string) error
EnsureVolume creates a volume if it doesn't exist.
func (*VolumeManager) RemoveVolume ¶
RemoveVolume removes a volume by name.
func (*VolumeManager) VolumeExists ¶
VolumeExists checks if a volume exists.