Skip to content
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

bashrc application variable entrypoints #1187

Open
shreddedbacon opened this issue Dec 8, 2024 · 0 comments
Open

bashrc application variable entrypoints #1187

shreddedbacon opened this issue Dec 8, 2024 · 0 comments

Comments

@shreddedbacon
Copy link
Member

When running applications that we don't provide an image for, when crafting the images to run in Lagoon, we often have to create a new entrypoint file that sets up some environment variables so that the application is aware of them.

Typically this looks like an entrypoint script like my-app-entrypoint.sh

#!/bin/sh
export MYSPECIALVARIABLE=$(do stuff to craft my special variable)

Then copying it into the entrypoints in the dockerfile like so

COPY my-app-entrypoint.sh /lagoon/entryponts/my-app-entrypoint.sh

Then when the container starts, as long as the entrypoint runs all entrypoints, the variable will be available to my running app.

This is all great, but sometimes I need these variables when I ssh into a service in Lagoon. Currently the .bashrc file only sources 3 entrypoints when it runs, this means the only way to consume them is to source them first. This can be problematic if you forget to do so, or don't know you have to do it.

What could be nice is an established entrypoint name, and if it is present, sourced in .bashrc.

if [ -r "/lagoon/entrypoints/900-application-env.sh" ]; then
  # this is a way for users that exec in to consume custom application variables that are required to operate the application with a shell
  # since this is in an entrypoint, it will also be read when the container starts up so it is available to both runtime and shell
  source /lagoon/entrypoints/900-application-env.sh
fi

A current workaround is to just extend and then replace the existing /lagoon/entrypoints/55-generate-env.sh script with a custom one. Though I think having a dedicated one for this would be much nicer, and could be documented as the way to provide custom application variables.

There is also a somewhat relevant Lagoon issue when we start to consider pre and post rollout tasks and applications that leverage this method of application entrypoint variables.

@shreddedbacon shreddedbacon changed the title bashrc entrypoints bashrc application variable entrypoints Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant