incorrect detection of npm-start buildpacks leads to invalid entrypoint
dalbar opened this issue · comments
What happened?
I am trying to build a simple nodejs application using the paketo and noticed that the npm-start
buildpack sets an invalid entrypoint.
- What were you attempting to do?
Build an image for https://github.com/shipwright-io/sample-nodejs/tree/main/source-build
- What did you expect to happen?
Since the source directory does contain an app.js
, I expect it to be the entrypoint to the application as described in the paketo documentation.
- What was the actual behavior? Please provide log output, if possible.
The platform choses this buildpack which sets an invalid entrypoint to a non existing server.js
.
===> ANALYZING
Previous image with name "node-bug-sample" not found
===> DETECTING
5 of 10 buildpacks participating
paketo-buildpacks/ca-certificates 3.0.1
paketo-buildpacks/node-engine 0.11.2
paketo-buildpacks/npm-install 0.6.2
paketo-buildpacks/node-module-bom 0.2.0
paketo-buildpacks/npm-start 0.6.1
===> RESTORING
===> BUILDING
Paketo CA Certificates Buildpack 3.0.1
https://github.com/paketo-buildpacks/ca-certificates
Launch Helper: Contributing to layer
Creating /layers/paketo-buildpacks_ca-certificates/helper/exec.d/ca-certificates-helper
Paketo Node Engine Buildpack 0.11.2
Resolving Node Engine version
Candidate version sources (in priority order):
package.json -> ">= 0.10.12"
<unknown> -> ""
Selected Node Engine version (using package.json): 16.13.1
Executing build process
Installing Node Engine 16.13.1
Completed in 6.701s
Configuring build environment
NODE_ENV -> "production"
NODE_HOME -> "/layers/paketo-buildpacks_node-engine/node"
NODE_VERBOSE -> "false"
Configuring launch environment
NODE_ENV -> "production"
NODE_HOME -> "/layers/paketo-buildpacks_node-engine/node"
NODE_VERBOSE -> "false"
Writing profile.d/0_memory_available.sh
Calculates available memory based on container limits at launch time.
Made available in the MEMORY_AVAILABLE environment variable.
Paketo NPM Install Buildpack 0.6.2
Resolving installation process
Process inputs:
node_modules -> "Not found"
npm-cache -> "Not found"
package-lock.json -> "Not found"
Selected NPM build process: 'npm install'
Executing build process
Running 'npm install --unsafe-perm --cache /layers/paketo-buildpacks_npm-install/npm-cache'
Completed in 845ms
Configuring launch environment
NPM_CONFIG_LOGLEVEL -> "error"
Configuring environment shared by build and launch
PATH -> "$PATH:/layers/paketo-buildpacks_npm-install/modules/node_modules/.bin"
Paketo Node Module Bill of Materials Generator Buildpack 0.2.0
Resolving CycloneDX Node.js Module version
Selected CycloneDX Node.js Module version: 3.0.7
Executing build process
Installing CycloneDX Node.js Module 3.0.7
Completed in 254ms
Configuring environment
Appending CycloneDX Node.js Module onto PATH
Running CycloneDX Node.js Module
Running 'cyclonedx-bom -o bom.json'
Completed in 316ms
Paketo NPM Start Buildpack 0.6.1
Assigning launch processes
web: node server.js
The error output when running the image:
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '/workspace/server.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Build Configuration
- What platform (
pack
,kpack
,tekton
buildpacks plugin, etc.) are you
using? Please include a version.
pack - 0.23.0
- What buildpacks are you using? Please include versions.
paketo-buildpacks/ca-certificates 3.0.1
paketo-buildpacks/node-engine 0.11.2
paketo-buildpacks/npm-install 0.6.2
paketo-buildpacks/node-module-bom 0.2.0
paketo-buildpacks/npm-start 0.6.1
- What builder are you using? If custom, can you provide the output from
pack inspect-builder <builder>
?
paketobuildpacks/builder:full
- Can you provide a sample app or relevant configuration (
buildpack.yml
,
nginx.conf
, etc.)?
https://github.com/shipwright-io/sample-nodejs/tree/main/source-build and run $DIR/source-build$ pack build node-bug-sample --builder paketobuildpacks/builder:full
Checklist
- I have included log output.
- The log output includes an error message.
- I have included steps for reproduction.
Further observations
The behaviour described in the paketo documentation is contributed by the node-start buildpack. The npm-start
buildpack is falsely applied in this instance, because its detection criteria is the existence of a package.json
file. However, that package.json
file does not contain any start commands (pre-start, start...). Thus, it seems like the detection phase of this buildpack has to be extended to also check for a suitable start command. If not, then node-start
should be preferred.