Technical Articles
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 cf target
Locate the application or hdi container for which you’d like the source code and execute:
cf app your_app_name --guid 040b4e07-8fd2-4294-ab84-5328e5b73891 |
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.
Very handy! Thanks for sharing Remi.
And last but not least:
If you did find yourself in this position and you did fetch your application back from CF by using this approach, you really should think about a working CI/CD strategy for your needs!!! 😉
Anyway - Thx for this information Remi ASTIER !