Skip to content

Commit

Permalink
Merge #543
Browse files Browse the repository at this point in the history
543: Added environment variables to control the UID and GID in the container r=Dylan-DPC a=UebelAndre

`CROSS_CONTAINER_UID` and `CROSS_CONTAINER_GID` can now be used to control the user and group ID's passed to Docker.

I ran into this when trying to setup a Github-Action that runs on MacOS and uses docker-machine which wasn't working. I then found #389 which described the solution of updating the UID and GID which I've confirmed works. This change should make it easier for users to solve for the same issue without making a fork.

Co-authored-by: Andre Brisco <andre.brisco@gmail.com>
  • Loading branch information
bors[bot] and UebelAndre authored Mar 29, 2021
2 parents 97c4e1d + efb6e59 commit 58bfd65
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,14 @@ pub fn run(target: &Target,
// We need to specify the user for Docker, but not for Podman.
if let Ok(ce) = get_container_engine() {
if ce.ends_with(DOCKER) {
docker.args(&["--user", &format!("{}:{}", id::user(), id::group())]);
docker.args(&[
"--user",
&format!(
"{}:{}",
env::var("CROSS_CONTAINER_UID").unwrap_or(id::user().to_string()),
env::var("CROSS_CONTAINER_GID").unwrap_or(id::group().to_string()),
),
]);
}
}

Expand Down

0 comments on commit 58bfd65

Please sign in to comment.