90693fb32f
Funciones impuras para gestión de contenedores: docker_build_image, docker_compose_up/down, docker_volume_create/list/remove, generate_dockerfile, write_dockerfile, go_build_binary, health_check_http, deploy_app y stop_app. Todas con tests unitarios donde aplica. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
23 lines
639 B
Go
23 lines
639 B
Go
package infra
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
// DockerComposeDown baja un stack docker-compose desde el archivo dado.
|
|
// Si removeVolumes es true elimina también los volumes (-v). Retorna el stdout del comando.
|
|
func DockerComposeDown(composeFile string, removeVolumes bool) (string, error) {
|
|
args := []string{"compose", "-f", composeFile, "down"}
|
|
if removeVolumes {
|
|
args = append(args, "-v")
|
|
}
|
|
|
|
out, err := exec.Command("docker", args...).CombinedOutput()
|
|
if err != nil {
|
|
return "", fmt.Errorf("docker compose down %s: %s", composeFile, strings.TrimSpace(string(out)))
|
|
}
|
|
return strings.TrimSpace(string(out)), nil
|
|
}
|