-
Notifications
You must be signed in to change notification settings - Fork 1
/
magefile.go
77 lines (60 loc) · 1.97 KB
/
magefile.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//+build mage
package main
import (
"context"
"path"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
func buildDockerImage(dockerfile_base_path string, image_name string) error {
var registry_base string = "docker.pkg.github.com/nolte/vscode-devcontainers"
return sh.Run(
"docker",
"build",
"-f", path.Join(dockerfile_base_path, "Dockerfile"),
"-t", path.Join(registry_base, image_name),
path.Join(dockerfile_base_path, "."),
)
}
type VSCodeContainer mg.Namespace
//var Default = Build
var Aliases = map[string]interface{}{
"all": VSCodeContainer.Build,
}
// Build the base image
func (VSCodeContainer) BuildCommons() error {
return buildDockerImage("./images/commons", "commons")
}
// Add Golang to the BaseContainer
func (VSCodeContainer) BuildCommonsGolang() error {
return buildDockerImage("./images/commons-golang", "commons-golang")
}
func (VSCodeContainer) BuildDevops() error {
return buildDockerImage("./images/devops", "devops")
}
func (VSCodeContainer) BuildDevGolang() error {
return buildDockerImage("./images/dev-golang", "golang")
}
func (VSCodeContainer) BuildDevK8SOperator() error {
return buildDockerImage("./images/k8sOperator", "k8s-operator")
}
func (VSCodeContainer) BuildDevIOT() error {
return buildDockerImage("./images/iot", "iot")
}
func (VSCodeContainer) BuildDevNPM() error {
return buildDockerImage("./images/npm", "npm")
}
func (VSCodeContainer) BuildDevPython() error {
return buildDockerImage("./images/python", "python")
}
// Build all existing devcontainers in the expected order.
func (VSCodeContainer) Build(ctx context.Context) {
mg.CtxDeps(ctx, VSCodeContainer.BuildCommons)
mg.CtxDeps(ctx, VSCodeContainer.BuildCommonsGolang)
mg.CtxDeps(ctx, VSCodeContainer.BuildDevGolang)
mg.CtxDeps(ctx, VSCodeContainer.BuildDevops)
mg.CtxDeps(ctx, VSCodeContainer.BuildDevK8SOperator)
mg.CtxDeps(ctx, VSCodeContainer.BuildDevIOT)
mg.CtxDeps(ctx, VSCodeContainer.BuildDevNPM)
mg.CtxDeps(ctx, VSCodeContainer.BuildDevPython)
}