Skip to content

Commit

Permalink
Ignore node modules when packaging the tar.gz (#349)
Browse files Browse the repository at this point in the history
  • Loading branch information
kminehart authored Aug 13, 2024
1 parent ceda23b commit f202e86
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions artifacts/package_targz.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,14 @@ func (t *Tarball) BuildFile(ctx context.Context, b *dagger.Container, opts *pipe
targz.NewMappedDir("packaging/docker", grafanaDir.Directory("packaging/docker")),
targz.NewMappedDir("packaging/wrappers", grafanaDir.Directory("packaging/wrappers")),
targz.NewMappedDir("bin", backendDir),
targz.NewMappedDir("public", frontendDir),
targz.NewMappedDir("public", frontendDir, dagger.ContainerWithDirectoryOpts{
Exclude: []string{"node_modules", "*/node_modules", "**/*/node_modules"},
}),
targz.NewMappedDir("npm-artifacts", npmDir),
targz.NewMappedDir("storybook", storybookDir),
targz.NewMappedDir("plugins-bundled", pluginsDir),
targz.NewMappedDir("plugins-bundled", pluginsDir, dagger.ContainerWithDirectoryOpts{
Exclude: []string{"node_modules", "*/node_modules", "**/*/node_modules"},
}),
}

root := fmt.Sprintf("grafana-%s", version)
Expand Down
7 changes: 4 additions & 3 deletions targz/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"dagger.io/dagger"
)

func NewMappedDir(path string, directory *dagger.Directory) MappedDirectory {
return MappedDirectory{path: path, directory: directory}
func NewMappedDir(path string, directory *dagger.Directory, opts ...dagger.ContainerWithDirectoryOpts) MappedDirectory {
return MappedDirectory{path: path, directory: directory, opts: opts}
}

type MappedDirectory struct {
path string
directory *dagger.Directory
opts []dagger.ContainerWithDirectoryOpts
}

type MappedFile struct {
Expand Down Expand Up @@ -51,7 +52,7 @@ func Build(packager *dagger.Container, opts *Opts) *dagger.File {

for _, v := range opts.Directories {
path := path.Join(root, v.path)
packager = packager.WithMountedDirectory(path, v.directory)
packager = packager.WithDirectory(path, v.directory, v.opts...)
paths = append(paths, path)
}

Expand Down

0 comments on commit f202e86

Please sign in to comment.