Search code examples
reactjsdeploymentcloud-foundry

Staticfile deployment of built React app to Cloud Foundry seems to think it is a Node deployment, even with buildpack


I am currently trying to deploy a built React app to Cloud Foundry. The React is nothing special and packages into a set of static files with no issues. However, when I try and deploy to CF, I get the follow error:

16:24:44.467: [APP/PROC/WEB.0] bash: npm: command not found
16:24:44.519: [APP/PROC/WEB.0] Exit status 127

This is my manifest, which is why I am extremely confused as to why this error is occuring.

applications:
- name: whatever
  path: build
  memory: 64M
  instances: 1
  disk_quota: 1024M
  buildpacks: 
  - https://github.com/cloudfoundry/staticfile-buildpack.git

I've tried deploying both from the top level folder as well as from inside the build folder, and I've tried including the Node buildpack as well (which I know won't work because it has no directive to npm start).

Full log of deployment is here:

16:21:27.583: [STG.0] -----> Running go build supply
16:21:27.583: [STG.0] /tmp/buildpackdownloads/49e489d3547d6eb82fdd6227f8309290 ~
16:21:34.358: [STG.0] ~
16:21:34.389: [STG.0] -----> Staticfile Buildpack version 1.4.43
16:21:34.389: [STG.0]        **WARNING** 
16:21:34.389: [STG.0]        !! !!
16:21:34.389: [STG.0]        This application is being deployed on cflinuxfs2 which is being deprecated in April, 2019.
16:21:34.389: [STG.0]        Please migrate this application to cflinuxfs3.
16:21:34.389: [STG.0]        For more information about changing the stack, see https://docs.cloudfoundry.org/devguide/deploy-apps/stacks.html
16:21:34.389: [STG.0]        !! !!
16:21:34.389: [STG.0] -----> Installing nginx
16:21:34.389: [STG.0]        Using nginx version 1.15.12
16:21:34.389: [STG.0] -----> Installing nginx 1.15.12
16:21:34.389: [STG.0]        Copy [/tmp/cache/final/dependencies/742479b4d3f80b641ae394b6c5699e126e53f25198dfbcd9a5e54b66413ecba0/nginx-1.15.12-linux-x64-cflinuxfs2-4d0440ef.tgz]
16:21:34.667: [STG.0] -----> Running go build finalize
16:21:34.667: [STG.0] /tmp/buildpackdownloads/49e489d3547d6eb82fdd6227f8309290 ~
16:21:38.930: [STG.0] ~
16:21:38.951: [STG.0] -----> Root folder /tmp/app
16:21:38.951: [STG.0] -----> Copying project files into public
16:21:38.954: [STG.0] -----> Configuring nginx
16:21:39.207: [API.1] Creating droplet for app with guid 3df28cf5-8faf-40ef-a4e7-4e9658df9926
16:21:40.395: [STG.0] Exit status 0
16:21:40.395: [STG.0] Uploading droplet, build artifacts cache...
16:21:40.396: [STG.0] Uploading build artifacts cache...
16:21:40.396: [STG.0] Uploading droplet...
16:21:40.780: [STG.0] Uploaded build artifacts cache (2.7M)
16:21:42.060: [STG.0] Uploaded droplet (3.1M)
16:21:42.062: [STG.0] Uploading complete
16:21:42.134: [STG.0] Cell 3a98d2c0-2583-48dd-aa40-b72fe78267cf stopping instance bd85c2ad-6a00-405f-bbf0-c96d429fda43
16:21:42.134: [STG.0] Cell 3a98d2c0-2583-48dd-aa40-b72fe78267cf destroying container for instance bd85c2ad-6a00-405f-bbf0-c96d429fda43
16:21:45.333: [STG.0] Cell 3a98d2c0-2583-48dd-aa40-b72fe78267cf successfully destroyed container for instance bd85c2ad-6a00-405f-bbf0-c96d429fda43
16:21:46.397: [API.1] Process has crashed with type: "web"
16:21:46.422: [API.1] App instance exited with guid 3df28cf5-8faf-40ef-a4e7-4e9658df9926 payload: {"instance"=>"60e81bb4-79cd-4a42-6101-359c", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 127", "crash_count"=>2, "crash_timestamp"=>1562358175613734337, "version"=>"7e7a157a-d48a-47fc-863b-80193bad0461"}
16:21:47.750: [API.4] Process has crashed with type: "web"
16:21:47.768: [API.4] App instance exited with guid 3df28cf5-8faf-40ef-a4e7-4e9658df9926 payload: {"instance"=>"9059dfda-9fec-4c82-4a11-1ab1", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 127", "crash_count"=>1, "crash_timestamp"=>1562358172401034750, "version"=>"7e7a157a-d48a-47fc-863b-80193bad0461"}
16:21:49.934: [API.1] Process has crashed with type: "web"
16:21:49.956: [API.1] App instance exited with guid 3df28cf5-8faf-40ef-a4e7-4e9658df9926 payload: {"instance"=>"7f4ddf22-07d6-4f3f-62c1-ca68", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 127", "crash_count"=>3, "crash_timestamp"=>1562358179064113054, "version"=>"7e7a157a-d48a-47fc-863b-80193bad0461"}
16:22:46.283: [CELL.0] Cell 14d1eaac-45f2-4f93-9995-d8d80b86693d creating container for instance 60e81bb4-79cd-4a42-6101-359c
16:22:47.099: [CELL.0] Cell 14d1eaac-45f2-4f93-9995-d8d80b86693d successfully created container for instance 60e81bb4-79cd-4a42-6101-359c
16:22:48.304: [CELL.0] Starting health monitoring of container
16:22:48.821: [APP/PROC/WEB.0] bash: npm: command not found
16:22:48.858: [APP/PROC/WEB.0] Exit status 127
16:22:48.864: [CELL/SSHD.0] Exit status 0
16:22:49.421: [CELL.0] Cell 14d1eaac-45f2-4f93-9995-d8d80b86693d stopping instance 60e81bb4-79cd-4a42-6101-359c
16:22:49.421: [CELL.0] Cell 14d1eaac-45f2-4f93-9995-d8d80b86693d destroying container for instance 60e81bb4-79cd-4a42-6101-359c

I expect that the static files should be served, but I don't understand why NPM is necessary. I don't understand why NPM would be called from the build folder of static files, using the Staticfile buildpack.


Solution

  • Thanks to Daniel Mikusa up above, I was able to solve this. I had originally deployed to this specifically named service on Cloud Foundry as a Node project with the Node buildpack before changing my workflow to use the Staticfile buildpack on the same container. I believe what has happened is since the Node buildpack sets a start command, it remained cached on the container and since the Staticfile buildpack didn't override it, it remained. Even when I deleted and deployed to the same name service, the start command persisted. I did exactly what Daniel said to do (newly named service, change my manifest to simply use -staticfile_buildpack rather than any git link) and have no issues.