-
Notifications
You must be signed in to change notification settings - Fork 0
/
mage.go
47 lines (39 loc) · 863 Bytes
/
mage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// +build mage
package main
import (
"fmt"
"path/filepath"
"github.com/magefile/mage/sh"
)
const (
name = "mapp-ui-sdk"
buildImage = "node:11.7"
)
func Install() error {
return frontDockerCmd(name+"-install", "", "yarn", "install")
}
func Build() error {
return frontDockerCmd(name+"-build", "", "yarn", "build")
}
func Shell() error {
return frontDockerCmd(name+"-shell", "", "bash")
}
func frontDockerCmd(name, port string, cmd ...string) error {
p, _ := filepath.Abs(".")
args := []string{"run", "--rm",
"--name", name,
"--network", "lana-local",
"-v", fmt.Sprintf("%v:/front", p),
"-w", "/front",
"-it", // Interactve!
}
if port != "" {
args = append(args,
"--label", "traefik.enable=true",
"--expose", port,
)
}
args = append(args, buildImage)
args = append(args, cmd...)
return sh.RunV("docker", args...)
}