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
Dockerfile: run as user: linuxbrew #11815
Dockerfile: run as user: linuxbrew #11815
Conversation
First rebase: updating the commit message for clarity. |
I neglected to mention that yes, it is possible for the user to manually override this by mapping the files into a different path, and updating the working directory when running the image, however, this is cumbersome, and we can (and should) do better. |
Would like to leave this as-is. We need this in our CI jobs and various bits of Homebrew functionality assume it is cloned (for now, at least).
Optimisation at the end seems best to us. We'd rather avoid a smaller base image or omitting anything from
This makes sense to me but interested what @iMichka and @Homebrew/linux think. |
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.
😍 great work so far @sudoforge. Would love @Homebrew/linux @iMichka to take a look too.
To be clear -- Homebrew needs the git history of the
I'm not sure I'm following you. Why would Homebrew's maintainers want to avoid a smaller base image? As an example, there is nothing in the dependency list (as far as I can tell) that is not available on Alpine Linux. |
@sudoforge Hi, Ben. Thanks for this work. I'm camping this week, so I'll do my best with a quick reply now, but I'll be able to reply in more detail next week. Please submit one PR for each isolated change that you would like to make. It will help to focus the discussion, and permit closing PRs with changes that we don't wish to make, while keeping merging PRs with changes that we do wish to make, or discussing changes in PRs that need changes.
That's how it used to be, and it was intentionally switch from user |
There's no such thing as a free lunch. 😁 A smaller base image has less functionality. The |
Correct. The A separate Docker image could be maintained by a motivated third party that has the formulae, but not the Git history, has We have discussed possible improvements to Homebrew that do not require "tapping" (cloning) the Git history to be able to |
Please separate functional changes from performance improvements. |
This commit refactors the Dockerfile in order to resolve build errors caused by attempting to execute `brew` commands as the root user. We need to create the `/home/linuxbrew/.linuxbrew` folder prior to copying the local directory into `/home/linuxbrew/.linuxbrew/Homebrew` (and ensure the appropriate user owns it), as failing to do so will create `/home/linuxbrew/.linuxbrew` with root user and group ownership, causing the subsequent `mkdir` command called in the second `RUN` instruction to fail. closes #11802
This PR has been updated to only include the absolute necessary work to get the image working again. The description and commit message have been updated as well. |
Yes.
👍🏻. Also: we use this image to build our binary packages. Perhaps we could consider eventually having a "Homebrew maintainers/CI image" and a "end-users consumption image" (the latter being as small as possible).
Even in this case: we'll likely still need that data in this Docker image for our CI usage. |
Today I learned about |
I think using this for the initial "bootstrap" for user installs would also make things easier to setup because we wouldn't need to have a new enough |
Just be warned: this is intentionally undocumented and I'm pretty sure I'm the only one who's done any sort of testing on it so please don't use it in any user-facing ways at the moment until we've had maintainers test it and have documented it officially in You'd still need some version of |
Yes, please don't encourage any non-maintainer use yet, thanks. |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?There are additional improvements that the container image could still benefit from, namely:
homebrew/homebrew-core
viagit
. This causes the build to hang for some time (on the order of several minutes; I haven't timed it precisely). We could instead bring these source files in via anADD
instruction, pulling an archive from GitHub directly.docker run --rm -v "$(pwd):/home/linuxbrew/.linuxbrew" homebrew/brew brew <command>
. This is a bit verbose, and also isn't ideal, as paths inPWD
that are mounted into the container can overwrite preexisting paths within the container, and as with this repository (when runningbrew {style,typecheck,tests}
), can potentially lead to lengthy runtimes due to re-fetching of the dependencies.I will plan to submit PRs for the above recommendations over the next few weeks. I'd like to get it done sooner, but time constraints and my unfamiliarity with the internal architecture of
brew
will likely lead to me not being able to iterate on this right away.