Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: Run web and nodejs containers as host UID:GID
In development mode we run Docker containers built using Blubber (<https://wikitech.wikimedia.org/wiki/Blubber>) as non-root users. We use docker-compose to mount the host computer's git clone of the Toolhub project over the container's /srv/app directory as a volume. At runtime we expect processes inside the container to modify the mounted volume and for those modifications to match the UID:GID of the user on the host who launched the docker-compose stack. When the host is running macOS and Docker Desktop this all "just works" due to some magic in the volume driver used by Docker Desktop. Docker for Linux does not have an obvious analogous solution, so we had to figure out a work around. * When generating the user's initial .env file, add LOCAL_UID and LOCAL_GID values based on the effective UID/GID of the user on the host system. * Set the runtime user of our web and nodejs containers to "${LOCAL_UID}:${LOCAL_GID}" using the `user` attribute of a docker-compose service. * Create a $HOME directory owned by the runtime $LOCAL_UID user in the nodejs container before attempting to execute any `npm ...` commands so that npm will be able to create and manage a $HOME/.npm config and cache directory. * Profit!! Bug: T295318 Change-Id: I5f66cbde2d894672a996045d1ee5067ff06027ea
- Loading branch information