tomeichlersmith / denv

uniformly interact with containerized environments across runners
https://tomeichlersmith.github.io/denv/
GNU General Public License v3.0
8 stars 2 forks source link

MacOS Support Meta-Issue #117

Open tomeichlersmith opened 2 months ago

tomeichlersmith commented 2 months ago

This issue is focused on discussion and notes related to supporting MacOS. Related issues that hold some history on this topic are


Containers are an inherently Linux technology. The only way containers are spawned on non-Linux operating systems like MacOS and Windoze is via a Linux VM. On Windoze, docker instructes installers to use WSL which is helpful for us because that encourages the user to directly interact with a Linux shell hosting the containers. This makes Windoze "support" rather natural - just use the tightly-integrated WSL VM and you are good to go.

The MacOS ecosystem is a bit more complicated. From what I can tell, there are two main "camps". For our purposes, the Lima route seems preferable since, like WSL, the "middle layer" of the Linux VM is exposed to the user. However, the Docker on Mac route is already embraced by many of the users I'm developing this program for and may exist for a long time. With this in mind, I'd like to at least understand how to support some subset of the denv abilities for this route.

Docker on Mac

Docker on Mac (DoM) enables docker by launching VMs under-the-hood (I presume), but understanding this technology is a bit complicated since it is proprietary (as far as I can tell).

Lima

Launch tightly-integrated Linux VMs via lima and then run whatever container runner you want (they have apptainer, podman, docker, and nerdctl templates already). With daemon-based runners like docker, you can even have the "client" CLI be outside the VM and redirected to the "host" daemon inside the VM so it appears native. There is even another package colima which acts like the daemon directly. I suspect that Docker on Mac does something similar.

tomeichlersmith commented 2 months ago

The basic lima denv ... seems to run as expected. The only failing test is checking the group id. And I'm unsure at the moment if the groupid is only mismatched between container and VM since I'm running the entire testing suite inside the lima VM.

Full Test Output Log Installed lima v0.22.0 and `brew install qemu` on macos-13. Ran ``` $ limactl start \ --name=default \ --mount-writable \ template://docker $ lima TMPDIR=/tmp/lima ./ci/test docker INFO: Testing denv with 'docker' 1..35 ok 1 print version of denv ok 2 print check help ok 3 print config ok 4 change image being used ok 5 add a new mount ok 6 change shell program ok 7 disable network connection ok 8 basic check run ok 9 quiet check run ok 10 check fails when using unsupported runner ok 11 check that we are in a workspace ok 12 check that we are not in a workspace ok 13 denv name available in denv ok 14 we can share host environment variables ok 15 we can prevent sharing of host env vars ok 16 we can copy specific env vars ok 17 we can set (and override) env vars ok 18 pass exit code onto caller ok 19 call a simple executable non-interactively ok 20 by-pass broken .bashrc if non-interactive ok 21 no init denv should fail ok 22 can print denv help without a denv ok 23 can print denv init help without a denv ok 24 can print denv config help without a denv ok 25 can print denv config env help without a denv ok 26 denv can init ok 27 denv should not init twice ok 28 we can connect a socket to a Google public DNS server ok 29 we can disable network devices ok 30 whoami matches inside and outside denv not ok 31 file created inside denv has id match # tags: macos # (from function `assert_equal' in file test/test_helper/bats-assert/src/assert_equal.bash, line 40, # in test file test/ownership.bats, line 32) # `assert_equal "$(cat file-from-denv-ownership)" "$(id -u ${USER}):$(id -g ${USER})"' failed # # -- values do not equal -- # expected : 501:1000 # actual : 501:0 # -- # ok 32 run minimal shebang requiring readable workspace ok 33 pass arguments to the script ok 34 shebang with neither requirements met errors out ok 35 minimal shebang without readable workspace ```