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

Support running all docker images locally #2698

Closed

Conversation

dennisschagt
Copy link
Member

Resolves #2474

Changes based on a stackoverflow post.

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.
@coveralls
Copy link

coveralls commented Mar 10, 2024

Coverage Status

coverage: 59.893%. remained the same
when pulling 4c81d14 on dennisschagt:docker-local-ubuntu-23.10
into 0573564 on newsboat:master.

Copy link
Member

@Minoru Minoru left a 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
# .
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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)

@dennisschagt
Copy link
Member Author

Closing this in favor of #2729
Still, thanks for the review!

@dennisschagt dennisschagt deleted the docker-local-ubuntu-23.10 branch April 7, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Figure out how to use our Docker images locally
3 participants