How can I preserve execute bits for files during 'cf push' for Node apps?

130 Views Asked by At

I need to push a node application that will be executing a bash script and the script file needs to have the execute bit set. Can the cf command line utility allow me to set execute permission?

If it doesn't, can I do something during the staging cycle of my app to set execute permission bits?

1

There are 1 best solutions below

0
On BEST ANSWER

A script that has the execute bit set will also have it set when being pushed.

If you need to have a script invoked as part of staging or pushing the app, there are two options:

Invoke script during staging

Use scripts.preinstall stanza in package.json to run scripts during staging (during npm install, see here for more options), and include that script with your application:

"scripts": {
  "start": "node app.js",
  "preinstall": "./configure"
},

Invoke script after staging

If the script can be run before app is started, but after staging, use .profile.d. Before your app is started in the container (after staging), a bash shell will run all scripts in your .profile.d folder.

For example, I could have a my_app/.profile.d/aScript.sh file with:

export key=value or chmod +x some_file