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

Confusing shell prompt when accessing container #968

Open
tnelson-doghouse opened this issue Apr 11, 2024 · 7 comments
Open

Confusing shell prompt when accessing container #968

tnelson-doghouse opened this issue Apr 11, 2024 · 7 comments

Comments

@tnelson-doghouse
Copy link

Hi!

We have a container that inherits via a long chain from the lagoon CLI container. The container itself is called "worker". When staff log in, the prompt says they're logged into cli, not worker. "hostname" and $SERVICE_NAME show the correct values (SERVICE_NAME shows 'worker', but I'm not sure where that's coming from).

I'd like to suggest some changes that would make fixing this easier.

In this file: https://github.com/uselagoon/lagoon-images/blob/main/images/commons/.bashrc

  • Make a new directory, say /lagoon/bashrc
  • From /lagoon/bashrc, put in softlinks to all the files mentioned in the .bashrc file I linked above
  • In the .bashrc file linked above, do source /lagoon/bashrc/*
  • Add the PS1 transformation code as a new file to /lagoon/bashrc

It'd also mean that .bashrc would essentially never have to be changed -- just put things in /lagoon/bashrc

This would make it easy for us to just override the PS1 transformation code without worrying about the rest.

HTH!

@shreddedbacon
Copy link
Member

shreddedbacon commented Apr 11, 2024

SERVICE_NAME is added in via the templates during a build. Not in the container image.

Edit: This is provided here, but not in all templates. This is an issue with the templates which will be resolved soon. (I'm going to hide the further responses regarding this variable now though)

@tnelson-doghouse

This comment was marked as off-topic.

@shreddedbacon

This comment was marked as off-topic.

@shreddedbacon shreddedbacon changed the title Prompt confusing Confusing shell prompt when accessing container Apr 11, 2024
@rocketeerbkw
Copy link
Member

the prompt says they're logged into cli, not worker

I assume you're talking about the @cli-drupal part in this example: [drupal-example]main@cli-drupal. That's not the service name, it's the LAGOON env var which is set in the Dockerfile of all our base images. If your worker service is built from the cli then it will have that set in LAGOON. You can add an override in your Dockerfile.

The prompt has never been "what service are you in," only "what image are you in."

@tnelson-doghouse
Copy link
Author

@rocketeerbkw , agreed. But I'd like to change that, because it's confusing our staff. If the change above is made (ie. the reorganisation of existing content), then I can override that prompt code fairly easily. I mean, I could now, but it wouldn't pick up future changes to .bashrc, and I'd have to worry about those. I think if we do it the way I mentioned, then it'll give more flexibility in overriding this.

As an aside, the main modification we make to .bashrc now is adding extra files in that directory to run. If this change were made, we could convert all those to softlinks and not have to mess with .bashrc.

HTH,

@tnelson-doghouse
Copy link
Author

tnelson-doghouse commented Apr 11, 2024

Clarification: I'd like to change that for us, not for all Lagoon. All I'm after is the capability to override easily. As it is, my best bet is probably to write a patch file for .bashrc and apply it in our build pipeline, or something like that.

@shreddedbacon
Copy link
Member

Clarification: I'd like to change that for us, not for all Lagoon. All I'm after is the capability to override easily. As it is, my best bet is probably to write a patch file for .bashrc and apply it in our build pipeline, or something like that.

If you have an idea that would allow it to work as it does now, but with the ability for you/your team to override it, feel free to submit a PR for review

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

3 participants