feat: manage vector container via compose

Using compose instead of manual docker calls allows folks to customize the vector container by using a custom compose.yml template file. This opens us up to more customizations while aligning container management with how we do other external containers (such as for the proxy plugins).

Refs #5784
This commit is contained in:
Jose Diaz-Gonzalez
2024-01-26 06:45:24 -05:00
parent 3dc917253b
commit c49322bd34
7 changed files with 210 additions and 86 deletions

View File

@@ -33,6 +33,18 @@ func ContainerStart(containerID string) bool {
return true
}
// ContainerRemove runs 'docker container remove' against an existing container
func ContainerRemove(containerID string) bool {
cmd := sh.Command(DockerBin(), "container", "remove", "-f", containerID)
cmd.Stdout = nil
cmd.Stderr = nil
if err := cmd.Run(); err != nil {
return false
}
return true
}
// ContainerExists checks to see if a container exists
func ContainerExists(containerID string) bool {
cmd := sh.Command(DockerBin(), "container", "inspect", containerID)
@@ -259,6 +271,15 @@ func GetWorkingDir(appName string, image string) string {
return workDir
}
func IsComposeInstalled() bool {
result, err := CallExecCommand(ExecCommandInput{
Command: DockerBin(),
Args: []string{"info", "--format", "{{range .ClientInfo.Plugins}}{{if eq .Name \"compose\"}}true{{end}}{{end}}')"},
CaptureOutput: true,
})
return err == nil && result.ExitCode == 0
}
// IsImageCnbBased returns true if app image is based on cnb
func IsImageCnbBased(image string) bool {
if len(image) == 0 {