Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ensure Docker user UID:GID matches host user UID:GID #403

Merged
merged 4 commits into from
May 22, 2020

Conversation

glasnt
Copy link
Member

@glasnt glasnt commented May 22, 2020

This is a doozy.

Recent changes to Briefcase included using Docker for ease of ensuring a consistent build environment for linux. Cross-operating system building (building linux on macos) works to a degree, and this Docker-based installation works fine on macos.

However.

Differences in implementation details of Docker for Desktop and docker-ce means that when saving computed output in mounted volumes, the owner of the created files differs between environments.

In macOS (the most tested usecase), this is the local user and their group (for macOS, the user and the group wheel, GID 20)
In linux, this is root:root.

Once the processing is done within the container and computation continues on the host system, the linux build process on linux fails, because there is an ownership issue, given the computed files are owned by root:root

The way to fix this is to ensure that the user being used matches the UID:GID of the host. How? By passing those though in the build args (this PR), and using those values to create a user and optionally group in the Dockerfile (see beeware/briefcase-linux-appimage-template#1).

Why optionally? Ah, because of that wheel issue. Users in linux and macOS are guaranteed [citation needed] to have an ID larger than 500. Except wheel has an ID of 20, which can overload. So, we optionally create the group with the matching ID, but always create the user. In theory the user should always be created. The name of this user/group doesn't matter, as long as the UID/GID match. In our case, we make sure the home directory is reasonable given the username we chose (brutus, group briefcase)

A note for potential future explorers: given this PR uses the current user ID, in a multi-user setup where the same linux system is used by multiple briefcase application developers and Docker image caches are shared, there could potential ownership issues should the base Docker image be used from a cache of a different user with a different UID, hence re-introducing the ownership issue this PR seeks to fix.

(In all references, macOS is macOS Catalina, linux is Ubuntu 19.04, for the testing of this PR)

@glasnt glasnt force-pushed the topic/dockeruser branch 2 times, most recently from 79684d3 to 87b49c4 Compare May 22, 2020 07:25
@glasnt glasnt changed the title Ensure Dockerfile user matches uid/gid of host user Ensure Docker user UID:GID matches host user UID:GID May 22, 2020
@glasnt glasnt force-pushed the topic/dockeruser branch from 87b49c4 to c7abed9 Compare May 22, 2020 07:27
@glasnt glasnt force-pushed the topic/dockeruser branch from 048cc08 to fbccad6 Compare May 22, 2020 07:59
@glasnt glasnt requested a review from freakboy3742 May 22, 2020 08:06
Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Awesome stuff - thanks for the fix!

@freakboy3742 freakboy3742 merged commit ae21152 into beeware:master May 22, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants