redhat-buildpacks / testing

Project aiming to help us to perform e2e tests using Buildpacks
Apache License 2.0
0 stars 3 forks source link

Tekton build of node.js: npm install failed: exec: "npm": executable file not found in $PATH #36

Closed cmoulliard closed 1 year ago

cmoulliard commented 1 year ago

Issue

During the execution of the following bash script able to install a Tekton builldpack pipelineRun for a node.js project, the step build reports such an error

Timer: Builder started at 2023-08-24T10:27:18Z

Paketo Buildpack for CA Certificates 3.6.3
  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 Buildpack for Node Engine 1.7.0
  Resolving Node Engine version
  Node no longer requested by plan, satisfied by extension
  Setting up launch layer for environment variables
  Configuring build environment
    NODE_ENV     -> "production"
    NODE_HOME    -> "/layers/paketo-buildpacks_node-engine/node"
    NODE_OPTIONS -> "--use-openssl-ca"
    NODE_VERBOSE -> "false"

  Configuring launch environment
    NODE_ENV     -> "production"
    NODE_HOME    -> "/layers/paketo-buildpacks_node-engine/node"
    NODE_OPTIONS -> "--use-openssl-ca"
    NODE_VERBOSE -> "false"

    Writing exec.d/0-optimize-memory
      Calculates available memory based on container limits at launch time.
      Made available in the MEMORY_AVAILABLE environment variable.

Paketo Buildpack for NPM Install 1.2.0
  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 launch environment install process
    Running 'npm install --unsafe-perm --cache /layers/paketo-buildpacks_npm-install/npm-cache'
npm install failed: exec: "npm": executable file not found in $PATH
Timer: Builder ran for 476.513584ms and ended at 2023-08-24T10:27:18Z
ERROR: failed to build: exit status 1

Detect phase seemed to worked well ...

Warning: Platform requested experimental feature 'Dockerfiles'
Timer: Detector started at 2023-08-24T10:27:14Z
======== Output: paketo-buildpacks/node-run-script@1.0.11 ========
could not find script(s) [build] in package.json
err:  paketo-buildpacks/node-run-script@1.0.11 (1)
======== Output: paketo-buildpacks/node-run-script@1.0.11 ========
could not find script(s) [build] in package.json
err:  paketo-buildpacks/node-run-script@1.0.11 (1)
6 of 12 buildpacks participating
paketo-community/ubi-nodejs-extension 0.0.1
paketo-buildpacks/ca-certificates     3.6.3
paketo-buildpacks/node-engine         1.7.0
paketo-buildpacks/npm-install         1.2.0
paketo-buildpacks/node-start          1.1.0
paketo-buildpacks/npm-start           1.0.12
Timer: Detector ran for 494.570292ms and ended at 2023-08-24T10:27:15Z
Timer: Generator started at 2023-08-24T10:27:15Z
Ubi Node.js Extension 0.0.1
  Resolving Node Engine version
    Candidate version sources (in priority order):
      package.json -> "18 || 16"
      <unknown>    -> ""

  Selected Node Engine Major version 18
Warning: new runtime base image 'paketocommunity/run-nodejs-18-ubi-base' not found in run metadata
Timer: Generator ran for 19.722292ms and ended at 2023-08-24T10:27:15Z

Step completed successfully

Question: How is the following step running locally using pack ===> EXTENDING (BUILD)takes place using tekton task and buildpack phases ?

How to reproduce

Execute this bash script on a kubernetes kind cluster and change the:

IMAGE_NAME=quay.io/ch007m/nodejs-pack-test

echo "### Installing Tekton and Dashboard" kubectl apply -f https://github.com/tektoncd/pipeline/releases/download/v0.48.0/release.yaml kubectl apply -f https://storage.googleapis.com/tekton-releases/dashboard/latest/release.yaml

VM_IP=127.0.0.1 kubectl create ingress tekton-ui -n tekton-pipelines --class=nginx --rule="tekton-ui.$VM_IP.nip.io/*=tekton-dashboard:9097"

kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/git-clone/0.9/git-clone.yaml kubectl apply -f https://raw.githubusercontent.com/redhat-buildpacks/testing/ed213e2473a13e1c01c397a3e2857091dd557018/k8s/tekton/buildpacks-phases.yml

echo "##### Testing lifecycle with: " cat < auths.json { "auths": { "quay.io": { "auth": "Y2gwMDdt....NjJPMg==", } } } EOF

kubectl delete secret/dockercfg kubectl create secret generic dockercfg --from-file=.dockerconfigjson=auths.json --type=kubernetes.io/dockerconfigjson

kubectl delete PipelineRun/buildpacks-phases kubectl delete pvc/ws-pvc kubectl delete sa/sa-with-secrets

cat <<EOF | kubectl apply -f -

apiVersion: v1 imagePullSecrets:

tkn pipelinerun logs buildpacks-phases -f

cmoulliard commented 1 year ago

The problem is that currently no extender phase is part of the Tekton Buildpack task

mhdawson commented 1 year ago

@cmoulliard seems like you have figured it out :)

cmoulliard commented 1 year ago

seems like you have figured it out :)

Yes. I'm working on a PR to add the extender phase to the Tekton Task