-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime hooks #133
Comments
We have created an issue in Pivotal Tracker to manage this: https://www.pivotaltracker.com/story/show/130517887 The labels on this github issue will be updated when the story is started. |
Hi @thomaseizinger, Unless @nebhale is aware of any recent changes, I do not think it is possible to use a The documentation is confusing, because it sets Java-related environment variables in the example. @jncd, can you update that page to use non-Java environment variables and add a note mentioning that it is not possible to use a -Stephen |
The Java Buildpack makes no special considerations for a Whether or not there is support for it, I highly discourage using it. Including environmental configuration as part of an application is clear violation of the 12 Factor principals that separate application from the environment that it runs in. By tying the environment to the application (e.g. including a |
I've created a story in the CF Docs (Public) Tracker to update the Java Buildpack topic: |
Fixed error on page: https://docs.run.pivotal.io/devguide/deploy-apps/deploy-app.html#profile |
Thank you very much for your answers.
I would rather have a Are there any other hooks in cloudfoundry where I could define this logic? |
I agree that there are valid use cases for It's also worth pointing out that @nebhale how opposed would you be to allowing CF to evaluate a |
(Also, @thomaseizinger, FYI: |
@sclevine, thank you for putting together all this information. I already looked into some of these links and I am also very interested in finding a solution for this problem. |
I'd like to keep this issue open until Ben chimes in. If he decides that the Java buildpack should support |
Any news / progress on this? |
We have no plans to add any specific support for |
That helped a lot, thanks!
This is the content of a shell-script that is called before the app is pushed to CF via At least for me, this issue is now resolved. |
Thanks, @thomaseizinger. I'm closing this issue now that it's resolved. |
@thomaseizinger The other thing to remember is that you don't have to have the "final" result before the setting the environment variable. You can put in enough escaping to do something like:
(I freehanded that, so it might not be quite right) This means that the variable will be evaluated each time a container is created and if you rebind a service, you can restart the container without resetting the environment variable. |
That works? Nice! |
I've never tried it from the web UI, so I'm not sure if it's supported there or not (but I'd suspect yes). They key is that it requires a lot of escaping as the value is evaluated three times, and only the last evaluation will resolve the proper value. |
Are you sure that CF evaluates the value of the environment variable as a BASH expression before handing it over to the application?
When trying to start the application, the log prints:
|
I wouldn't expect see an evaluated version of the expression in |
I am not sure if quotes around the jq expression are the root of this problem. As far as I know, most of the code that runs CF is written in Go? I am not sure how passing a BASH-expression should work as I don't see any BASH-scripts involved when running / creating an instance of an application. (Except the above mentioned |
Since I stumbled upon this issue while looking for a similar solution I wanted to share my solution with you as well. Because I don't know my app's GUID but only its name (represented by cf ssh $APP_NAME -c "echo \$VCAP_SERVICES" | jq -r ".elephantsql[0].credentials.uri" This requires you to enable SSH in your CLI. Also note the Maybe this is helpful to someone else as well :) |
Thanks for sharing! That is indeed a helpful (and neat) solution and way better than the way I currently handle the problem. It might also be a good idea to include this in the docs somehow? |
We have a legacy application (binary) that we can launch using the java buildpack, but prior to tomcat running, we need to create a bunch of xml configuration (from VCAP_SERVICES) in the location where the app looks for it. being able to have a pre-run step would be very useful. I think multi buildpacks might solve it (or a fork of the buildpack). we can't use cf ssh in our instance as it's been explicitly blocked. |
Java & Binary apps can now use |
As of now it's included in the Java buildpack, it seems. Just include the .profile file in the jar or war file. |
I am having problems understanding the runtime hooks documentation at https://docs.run.pivotal.io/devguide/deploy-apps/deploy-app.html#profile.
As far as I understand the documentation, I have to put the
.profile
file into the root of my application directory.My directory structure looks like this when I SSH into the application:
├── app
│ ├── .java-buildpack // omitted
│ └── rest-api-0.0.3
│ ├── bin
│ │ ├── rest-api
│ │ ├── rest-api.bat
│ │ ├── run-minimal.bat
│ │ └── run-minimal.sh
│ ├── docs
│ │ └── index.html
│ ├── lib // omitted
│ └── .profile <-- this is my .profile file
├── .bash_logout
├── .bashrc
├── logs
├── .profile
├── staging_info.yml
├── tmp
└── tree
But the file does not get executed. My
.profile
file looks like this:echo "This is a test." > mytestfile
If it got executed, I would expect a file
mytestfile
anywhere in this directory structure.The
.profile
folder outside of myapp
directory is not under my control, the only thing thecf
CLI pushed to the server were the contents of theapp/
folder.Where do I have to place the
.profile
file in order to get executed?I am using the java-buildpack and my API endpoint is
https://api.run.pivotal.io (API version: 2.61.0)
.The text was updated successfully, but these errors were encountered: