bibendi / dip

The dip is a CLI dev–tool that provides native-like interaction with a Dockerized application.
MIT License
1.26k stars 44 forks source link

Current Docker host user UID special environment variable #167

Closed willtcarey closed 8 months ago

willtcarey commented 8 months ago

I'm doing some work with Docker bind mounts where our Rails app creates files through generators that are then not owned by our user outside of the docker container.

I'm working on getting around this by injecting the current user's UID into the Docker build but unfortunately the UID env var is not exported by default in most shells so it is not forwarded to the dip process. So to make this work for my team I need to get everyone to do add export UID=$UID or export UID=$(id -u) to their shell environment.

What I would like to do is have dip expose a special variable of the current host user's UID that I could set in the environment that gets forwarded on to docker compose, similar to the WORK_DIR and OS variables that get set currently. Alternatively, if a feature could be added to dynamically compute env vars in the dip config that would work as well (we could set the value of id -u to an ENV var).

There has been desire to do this in docker compose itself, but it's mostly gone nowhere because the Docker team wants to keep the docker compose file portable between systems, which makes sense. But I feel like dip can work a level above that and we can inject the platform independent values from the config or from Ruby.

I'm happy to do a PR to implement this, but I wanted to get some buy-in from the dip team or hear any concerns or objections you might have.

bibendi commented 8 months ago

Hi William,

We discussed this feature in that issue #153. If you are ready, we would appreciate it if you could implement it for us.

willtcarey commented 8 months ago

@bibendi Ah thank you. I missed that issue when I first searched for things. I'll submit a PR soon