darwin-containers / rund

OCI Container Runtime for Darwin
Apache License 2.0
432 stars 13 forks source link

Dockerfile with Homebrew #22

Open slonopotamus opened 8 months ago

slonopotamus commented 8 months ago

Something like this should work eventually

FROM ghcr.io/macoscontainers/macos-jail/ventura:latest
RUN mkdir /tmp /var/folders
ENV HOME=/
ENV NONINTERACTIVE=1
RUN bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
slonopotamus commented 8 months ago

Problem: Xcode build tools do not install properly.

Jaskowicz1 commented 7 months ago

Any update on this? Need it greatly so I can run a self-hosted GitHub runner in a container.

slonopotamus commented 7 months ago

Not yet.

Jaskowicz1 commented 7 months ago

Not yet.

Ah right. Keep it up though, this is a great project!

awdAvenger commented 7 months ago

I got the command line tools working by simply unpacking the download from apple.com. The next issue is that ruby is not working correctly as the ruby framework is missing (and maybe other parts as well) from the base image.

After messing around with ruby-install (which in turn requires openssl, which requires perl, which is not functional either on the base image) I was able to get brew installed.

Here are some of the steps required for this:

These steps would have been easier if the ventura image had a functional Ruby and/or Perl.

Jaskowicz1 commented 7 months ago

I got the command line tools working by simply unpacking the download from apple.com. The next issue is that ruby is not working correctly as the ruby framework is missing (and maybe other parts as well) from the base image.

After messing around with ruby-install (which in turn requires openssl, which requires perl, which is not functional either on the base image) I was able to get brew installed.

Here are some of the steps required for this:

  • Create /tmp and /var/folders and the /.dockerenv file
  • Extract Command Line Tools.pkg from the Command_Line_Tools.dmg using hdiutil attach. I was not able to do this from inside the container. Extract the Payload of the executables and the ventura SDK from the .pkg structure with pbzx to the root of the container and run 'xcode-select -r'
  • Mount a proper devfs in the container, it does not work as a bind mount and the /dev/fd files are needed for some of the following commands and brew itself: mount -t devfs devfs /dev
  • Place xzcat inside the container somehow, with it's dependant xz library. I snatched these from my local homebrew install.
  • Copy perl folders (/System/Library/Perl/5.30 and /System/Library/Perl/Extras/5.30) from local install to the container.
  • Download openssl (openssl.org/source/openssl-1.1.1w.tar.gz) and install by running ./config && make && make install
  • Download ruby-install from postmodern/ruby-install and install with make install
  • Install ruby with: ruby-install --system -c ruby 2.6.10
  • Install brew, but with some custom environment variables to use the new ruby: HOMEBREW_USE_RUBY_FROM_PATH=1 HOMEBREW_DEVELOPER=1 NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL Homebrew/install@HEAD/install.sh (raw))"

These steps would have been easier if the ventura image had a functional Ruby and/or Perl.

Does this allow you to run brew after? #18 talks about how you can't create additional users and Homebrew no longer supports people using root to use brew.

slonopotamus commented 7 months ago

Homebrew no longer supports people using root to use brew.

Just create a /.dockerenv file inside image and brew will stop complaining.

Jaskowicz1 commented 7 months ago

Homebrew no longer supports people using root to use brew.

Just create a /.dockerenv file inside image and brew will stop complaining.

Ahhhh, that's amazing!

slonopotamus commented 7 months ago

These steps would have been easier if the ventura image had a functional Ruby and/or Perl.

I've created https://github.com/macOScontainers/macos-jail/issues/13 to address that.

slonopotamus commented 7 months ago

I've updated Ventura image so it now includes Perl and Ruby files.

slonopotamus commented 6 months ago

Homebrew no longer supports people using root to use brew.

Just create a /.dockerenv file inside image and brew will stop complaining.

Starting with dockerd 0.0.7, this is done automatically: https://github.com/macOScontainers/moby/commit/07e0f0b22afa0a5a1c3486c5b1801860262d19ed