Skip to content

Commit

Permalink
fix: setting NODE_HOME to "" for ubi-nodejs-extension
Browse files Browse the repository at this point in the history
  • Loading branch information
pacostas authored and thitch97 committed Jan 16, 2024
1 parent 8e2feaf commit f9ed593
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ func Build(entryResolver EntryResolver, dependencyManager DependencyManager, sbo
return packit.BuildResult{}, err
}

nodeLayer.Launch, nodeLayer.Build, nodeLayer.Cache = true, false, false
nodeLayer.Launch, nodeLayer.Build, nodeLayer.Cache = true, true, false
nodeLayer.Metadata = map[string]interface{}{
BuildKey: false,
BuildKey: true,
LaunchKey: true,
}

nodeLayer.SharedEnv.Default("NODE_HOME", "")
} else {
logger.Candidates(allEntries)

Expand Down Expand Up @@ -175,14 +177,14 @@ func Build(entryResolver EntryResolver, dependencyManager DependencyManager, sbo
return packit.BuildResult{}, err
}
}
nodeLayer.SharedEnv.Default("NODE_HOME", nodeLayer.Path)
}

var optimizedMemory bool
if os.Getenv("BP_NODE_OPTIMIZE_MEMORY") == "true" {
optimizedMemory = true
}

nodeLayer.SharedEnv.Default("NODE_HOME", nodeLayer.Path)
nodeLayer.SharedEnv.Default("NODE_ENV", "production")
nodeLayer.SharedEnv.Default("NODE_VERBOSE", "false")
nodeLayer.SharedEnv.Default("NODE_OPTIONS", "--use-openssl-ca")
Expand Down
4 changes: 2 additions & 2 deletions build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
Expect(layer.Name).To(Equal("node"))
Expect(layer.Path).To(Equal(filepath.Join(layersDir, "node")))
Expect(layer.SharedEnv).To(Equal(packit.Environment{
"NODE_HOME.default": filepath.Join(layersDir, "node"),
"NODE_HOME.default": "",
"NODE_ENV.default": "production",
"NODE_VERBOSE.default": "false",
"NODE_OPTIONS.default": "--use-openssl-ca",
Expand All @@ -477,7 +477,7 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
}))

Expect(layer.Metadata).To(Equal(map[string]interface{}{
nodeengine.BuildKey: false,
nodeengine.BuildKey: true,
nodeengine.LaunchKey: true,
}))

Expand Down

0 comments on commit f9ed593

Please sign in to comment.