Yesterday a user of the Staticfile buildpack noted that cf push would fail to upload files & start the deployment sometimes. "It takes forever and fails". We spotted the root cause:

"Why is it uploading 26,000 files? The final project in dist folder only has a few."

The problem was that we were uploading the whole project repo - which was using grunt to build out a large complex static file project. It had a Staticfile referencing the final project subfolder:

root: dist  

But then he was pushing all 26,000 files; even though the buildpack was only going to use the dozen files in the dist folder.


And instead of pushing the whole project folder, we now only push the dist folder.

We can do this with the CLI:

cf push mainsite -p dist  

Or we can do this with a manifest.yml file:

- name: mainsite
  path: dist

Finally, we removed the ./Staticfile file and created a new, blank one in dist/Staticfile.

Your source project might now looks something like:

├── dist
│   ├── Staticfile
│   ├── css
│   ├── images
│   ├── index.html
│   └── js
├── manifest.yml
└── src

Summary: the dist folder is the only folder that is pushed; and we tell Cloud Foundry that it needs the Staticfile buildpack with an empty Staticfile.