-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuilder.go
55 lines (49 loc) · 1.85 KB
/
builder.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
package frontend
import (
"dagger.io/dagger"
)
// Builder mounts all of the necessary files to run yarn build commands and includes a yarn install exec
func Builder(d *dagger.Client, platform dagger.Platform, src *dagger.Directory, nodeVersion string, cache *dagger.CacheVolume) *dagger.Container {
container := WithYarnCache(
NodeContainer(d, NodeImage(nodeVersion), platform),
cache,
).
WithDirectory("/src",
src.
WithoutFile("go.mod").
WithoutFile("go.sum").
WithoutFile("go.work").
WithoutFile("go.work.sum").
WithoutDirectory("devenv").
WithoutDirectory(".github").
WithoutDirectory("docs").
WithoutDirectory("pkg").
WithoutDirectory("apps").
WithoutDirectory(".nx"),
dagger.ContainerWithDirectoryOpts{
Exclude: []string{
"*drone*",
"*.go",
"*.md",
},
},
).
WithWorkdir("/src")
// TODO: Should figure out exactly what we can include without all the extras so we can take advantage of caching better.
// This had to be commented because storybook builds on branches older than 10.1.x were failing.
// container = containers.WithDirectories(container, map[string]*dagger.Directory{
// ".yarn": src.Directory(".yarn"),
// "packages": src.Directory("packages"),
// "plugins-bundled": src.Directory("plugins-bundled"),
// "public": src.Directory("public"),
// "scripts": src.Directory("scripts"),
// })
// container = containers.WithFiles(container, map[string]*dagger.File{
// "package.json": src.File("package.json"),
// "lerna.json": src.File("lerna.json"),
// "yarn.lock": src.File("yarn.lock"),
// ".yarnrc.yml": src.File(".yarnrc.yml"),
// })
// This yarn install is ran just to rebuild the yarn pnp files; all of the dependencies should be in the cache by now
return container.WithExec([]string{"yarn", "install", "--immutable"})
}