feat(mage): add a target to stop services
This commit is contained in:
parent
60a52ee66f
commit
5dd6ab8ee6
1 changed files with 30 additions and 0 deletions
30
magefiles/stop.go
Normal file
30
magefiles/stop.go
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/magefile/mage/sh"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Stop(environment, service 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),
|
||||||
|
"stop",
|
||||||
|
service,
|
||||||
|
}
|
||||||
|
|
||||||
|
return sh.Run(command[0], command[1:]...)
|
||||||
|
}
|
Loading…
Reference in a new issue