services/magefiles/shutdown.go

30 lines
509 B
Go
Raw Normal View History

package main
import (
"fmt"
"os"
"github.com/magefile/mage/sh"
)
func Shutdown(environment string) error {
os.Setenv("MAGEFILE_VERBOSE", "true")
cfg, err := newConfig(environment)
if err != nil {
return fmt.Errorf("unable to load the configuration; %w", err)
}
os.Setenv("DOCKER_HOST", cfg.Docker.Host)
command := []string{
"docker",
"compose",
"--project-directory",
fmt.Sprintf("%s/%s/compose", rootBuildDir, environment),
"down",
}
return sh.Run(command[0], command[1:]...)
}