Recover the source code of a running HDI container or Cloud Foundry application
You might be in a situation where a colleague has published an application and has not committed the source in a repository so it’s running all right, but you might not know exactly what’s running 🙂
Here’s one way to solve the issue:
Start by logging into cloud foundry using the command line.
cf login --sso
API endpoint: https://api.cf.eu20.hana.ondemand.com Temporary Authentication Code ( Get one at https://login.cf.eu20.hana.ondemand.com/passcode ): Authenticating... OK
Then navigate to the cloud foundry target organization and space using
Locate the application or hdi container for which you’d like the source code and execute:
cf app your_app_name --guid
Finally, use the guid of your application to download the sources into a .tgz
cf curl -X GET /v2/apps/your_app_guid/download --output your_app_name.droplet.tgz
And voila ! The tgz will contain the source code and possibly dependent libraries so you might want to delete the dependency folder such as node_modules.