-
Notifications
You must be signed in to change notification settings - Fork 209
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
Support running all docker images locally #2698
Support running all docker images locally #2698
Conversation
The usermod/groupmod commands, called from entrypoint.sh, cause an ownership change on all files under /home/builder. This includes the files mapped into /home/builder/src by the docker mount option. Moving the mount location outside of home to avoid this potentially destructive operation having an effect on files outside of docker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I understood most of the changes, but I got a couple questions, please see them below.
@@ -9,7 +9,7 @@ | |||
# docker build \ | |||
# --tag=newsboat-code-formatting-tools \ | |||
# --file=docker/code-formatting-tools.dockerfile \ | |||
# docker | |||
# . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? It doesn't look like Dockerfiles use anything outside the docker directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not strictly necessary, however, I prefer to keep these consistent between all of our docker files.
In the buildtools docker files, I've used a COPY
command to pull in the new entrypoint.sh
so there it is was necessary to update the path (cirrus seems to always specify the root directory of the git checkout, without option to override it so I did have to include the docker/
part in the COPY
command)
# --mount type=bind,source=$(pwd),target=/home/builder/src \ | ||
# --user $(id -u):$(id -g) \ | ||
# --mount type=bind,source=$(pwd),target=/src \ | ||
# --user root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to specify the user here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach taken in this PR requires the entrypoint script to update the user/group id of the builder
user.
We need to be root to do that.
However, in the end, we want to run the build commands as the builder
user.
The main issue is that cirrus does not expose a way to specify a user, so it will use the user as specified by the last USER
statement in the docker file.
Cirrus also does not run the command specified by ENTRYPOINT
.
That makes it necessary to specify the builder
user at the end of the docker file.
However, locally, we do want to run the entrypoint script as root to fixup the user/group id in the container to match the user/group id of the host user.
That is why the --user root
option is necessary at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, this solution feels far too convoluted, so I plan to try a different approach
(specifying the uid/gid at buildtime. If it works I will create a PR in a bit)
Closing this in favor of #2729 |
Resolves #2474
Changes based on a stackoverflow post.