'How do I provide environmental variable with my custom Cloud Foundry buildpack?
I have extra simple custom sidecar buildpack. All it does in /bin/supply is downloading and untarring to $DEPS_DIR/$DEPS_IDX/mylibrary certain dependency library. Since I can have more than one sidecar buildpack I don't know $DEPS_IDX for mylibrary beforehand. I want to set up from within /bin/supply of my custom buildpack environment variable export MYLIBRARY_PATH=$DEPS_DIR/$DEPS_IDX/mylibrary so main application could use it. How do I do that? Where do I put that export?
I know that I can put that variable to manifest.yml or set up it with cf set-env but that's fragile and I want to set up env var close to place where I supply related dependency. I saw that some custom buildpacks write custom scripts to $DEPS_DIR/$DEPS_IDX/profile.d. I tried that but those scripts are never executed. Should I try to reach /etc/profile.d from /bin/supply?
Solution 1:[1]
Put script exporting that value to ${BUILD_DIR}/.profile.d/ directory (it's where app located at build). All scripts from there are moved to /etc/profile.d and sourced at buildpack launch. BUILD_DIR should be visible during /bin/supply
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ScalewingedAcidicorn |
