uselagoon / lagoon-images

This repository builds the images used in Lagoon and local development environments
Apache License 2.0
27 stars 32 forks source link

Confusing shell prompt when accessing container #968

Open tnelson-doghouse opened 5 months ago

tnelson-doghouse commented 5 months ago

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

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 commented 5 months ago

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 commented 5 months ago

Interesting. It's not set in the nginx or php containers. :)

shreddedbacon commented 5 months ago

Interesting. It's not set in the nginx or php containers. :)

Because that is a unique template that does things a little bit different to the others. Lets not pollute an issue with the images with issues from the build-deploy-tool though.

rocketeerbkw commented 5 months ago

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 commented 5 months ago

@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 commented 5 months ago

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 commented 5 months ago

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