Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

idf-docker-image.rst: Run with current user ID instead of root. (IDFGH-10773) #11987

Merged
merged 1 commit into from
Aug 23, 2023

Conversation

jimmo
Copy link
Contributor

@jimmo jimmo commented Aug 1, 2023

I'm from the MicroPython project, and I noticed an issue with someone trying to follow the instructions at https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html to build MicroPython. Specifically, our build uses git to embed version information. They also noticed that the generated build directory was owned by root.

I'm not a docker expert at all, so there might be better ways to solve this, but I've been using exactly this mechanism of using containers for building firmware for many years without trouble. (Although I typically use -v $HOME:$HOME -w $PWD -u $UID instead, but I think in this case using /project makes more sense).


Rather than running the command inside the container as root, which will mean that any build artifacts created will be owned by root on the host, run the command as the current user.

This requires setting a temporary home directory as idf.py will try to access e.g. ~/.cache, so just use /tmp inside the container which is ephemeral anyway.

This also allows the command to use git. without setting the user ID, docker run ... git status will fail with
fatal: detected dubious ownership in repository at '/project'

Also added the missing explanation for -w /project.

Rather than running the command inside the container as root, which will
mean that any build artifacts created will be owned by root on the host,
run the command as the current user.

This requires setting a temporary home directory as idf.py will try to
access e.g. ~/.cache, so just use /tmp inside the container which is
ephemeral anyway.

This also allows the command to use `git`. without setting the user ID,
`docker run ... git status` will fail with
    fatal: detected dubious ownership in repository at '/project'

Also added the missing explanation for `-w /project`.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
@CLAassistant
Copy link

CLAassistant commented Aug 1, 2023

CLA assistant check
All committers have signed the CLA.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Aug 1, 2023
@github-actions github-actions bot changed the title idf-docker-image.rst: Run with current user ID instead of root. idf-docker-image.rst: Run with current user ID instead of root. (IDFGH-10773) Aug 1, 2023
@dobairoland
Copy link
Collaborator

Thank you for the contribution!

@dobairoland
Copy link
Collaborator

sha=c7d511277163726434e08725b250cddb38c5c660

@dobairoland dobairoland added the PR-Sync-Merge Pull request sync as merge commit label Aug 2, 2023
@espressif-bot espressif-bot added Status: Reviewing Issue is being reviewed and removed Status: Opened Issue is new labels Aug 7, 2023
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: Reviewing Issue is being reviewed labels Aug 21, 2023
@espressif-bot espressif-bot merged commit c7d5112 into espressif:master Aug 23, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Sync-Merge Pull request sync as merge commit Resolution: NA Issue resolution is unavailable Status: Done Issue is done internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants