Distillery - exporting env vars before app start

Hi, my custom vm.args file have -name ${APP}@${RANCHER_IP}, APP env variable is set on container run meanwhile RANCHER_IP var is something I would export in pre_start_hook and this is the hook contents:
export RANCHER_IP=$(wget -qO- http://rancher-metadata.rancher.internal/latest/self/container/primary_ip)
But running the rel gives the error:
Can't set long node name! Please check your configuration
What’s interesting is that if I change name to -name demo@ and in running rel shell run System.get_env("RANCHER_IP"), I get correct result.
Any ideas what’s wrong? I believe I can move the hook to a simple .sh-script wrapping rel binary with it, but I think it’s more natural to use hooks here.

1 Like

You need to use REPLACE_OS_VARS here, and export those vars before running the release, such as with a wrapper script as you mentioned, or as part of the container startup. When doing a similar thing with k8s, I went the wrapper script route.

The reason hooks are not a good fit (right now anyway), is because distillery tries to make the guarantee that the release environment is initialized, leaving startup tasks like migrations, etc, to you to perform in the prestart hook without having to do that manually - but this comes after a lot of other stuff has been setup by the release script. I may introduce a pre_boot hook for this kind of thing, but so far there hasn’t been much demand for it.


Thanks for clarification, that’s what I thought, will go with a wrapper script then. But anyway I think pre_boot hook would be nice to have as well.

Preboot would be really nice for this type of thing.