darwin-containers/rund

Dockerfile with Homebrew

Opened this issue · 11 comments

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)"

Problem: Xcode build tools do not install properly.

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

Not yet.

Not yet.

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

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 (https://www.openssl.org/source/openssl-1.1.1w.tar.gz) and install by running ./config && make && make install
  • Download ruby-install from https://github.com/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 https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

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

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.

Homebrew no longer supports people using root to use brew.

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

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!

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

I've created darwin-containers/darwin-jail#13 to address that.

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

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: darwin-containers/moby@07e0f0b