webinstall / webi-installer-requests

This is just to house issues for requests for new Webi installers.
Mozilla Public License 2.0
5 stars 7 forks source link

Request for colima (Mac only/ WSL on Windows) #145

Open seanogor opened 1 month ago

seanogor commented 1 month ago

Reviewing this issue link and other package uploads that have been pulled in upstream, I'm torn about whether this is a suitable request (non-native Windows support, loved your backend banter allusions to PowerShell, I'm less hardline than I once was here). I would like to actually contribute this issue myself as I tick the boxes in terms of cheat sheet, multi platform releases.

The tool I would like to onboard is colima, a powerful replacement for the docker desktop, reusing all the nice cli goodness from your container cli of choice. 🚀

I gain hope from the Enterprise Cloud section, where I would like this to the first of a number of contributions:

image

It's not quite a perfect fit, but this ecosystem gives me hope about demystifying the daily drivers I believe our esteemed community members should enjoy!

Please give me a gentle YAY or NAY, sampler cheat sheet below, (one my other favourite projects is a cheat sheet on roids)

Colima is a "almost" plug and play replacement for docker desktop on macos

Colima is Docker for Mac tool built on Lima. Lima is a virtual machine tool for MacOS with automatic file sharing and port forwarding. Using Lima feels a lot like using WSL on Windows.

Lima launches Linux virtual machines with automatic file sharing and port forwarding (similar to WSL2), and containerd.

Lima can be considered as a some sort of unofficial “containerd for Mac”.

Colima builds on that foundation to run a VM with Docker installed and it also configures your local Docker context for you.

Running with TestContainers

For Testcontainers to find the Docker environment, you need this one-time step:

To get TestContainers to run in Intellij you might have to add the following lines to your ~/.zshrc file

after change run source ~/.zshrc

sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock

export DOCKER_HOST="unix://${HOME}/.colima/docker.sock"
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export TESTCONTAINERS_HOST_OVERRIDE=$(colima ls -j | jq -r '.address')

Starting colima on login

There are a few ways to start colima but the command that serves the most areas right now has

--network-address for assigning an external IP address to the environment.

--mount-type virtiofs Virtiofs is a shared file system that lets virtual machines access a directory tree on the host.

--cpu 2 --memory 4 --disk 10 as needed for the application e.g. see

start with config

network address defined for an external IP

colima start --cpu 2 --memory 4 --disk 10 --mount-type virtiofs --network-address

Docker Compose

Start Colima

colima start --cpu 2 --memory 4 --disk 10 --mount-type virtiofs --network-address

Add to service in docker-compose

user: "${UID}:${GID}"

Export current user UID and GID

export UID=$(id -u) && export GID=$(id -g)

Run docker/docker-compose

docker compose up

There are lots of configuration options but typically we want QEMU and sshfs

colima status

Example output

INFO[0015] colima is running using QEMU                 
INFO[0015] arch: aarch64                                
INFO[0015] runtime: docker                              
INFO[0015] mountType: sshfs                             
INFO[0015] socket: unix:///Users/slynch2/.colima/default/docker.sock 

Stopping and Deleting colima

Note deleting colima will delete all downloaded docker images

Stop via colima stop

Delete via colima delete

Staring VMs

colima start --cpu 8 --memory 8 --mount-type virtiofs

Logging in to registry with OSX Keychain

By default, docker will store your credentials in plain text .

They do, however, provide a means of reading credentials securely through various plugins. I would suggest the keychain plugin as the most straightforward in mac (most common context).

To configure registry access via keychain:

download the osxkeychain extension from here:

you probably want the one that ends in darwin-arm64, e.g. docker-credential-osxkeychain-v0.8.1.darwin-arm64

rename the downloaded file to docker-credential-osxkeychain

make it executable: sudo chmod +x docker-credential-osxkeychain

move it to your PATH for docker to find it: cp docker-credential-osxkeychain /usr/local/bin/

Update your config to use osxkeychain:

// In ~/.docker/config.json :
{
  "credsStore": "osxkeychain"
}

log in: docker login  registry

At some / various points in this process, it is likely that Apple’s security will kick in and block the keychain extension from running. If this happens, open System Settings -> Privacy & Security and scroll down. You should see a button somewhere to allow you to run the executable that was just blocked. Click the button, and then re-run whatever command or step you were at in the guide above to continue. If you’ve been successful, opening ~/.docker/config.json should show no credentials, but an empty object for registry:

{
        "auths": {
                "registr": {}
        },
        "credsStore": "osxkeychain",
        "currentContext": "colima"
}

Remove Docker Desktop

This is a very good idea as it will free up space and resources, it will also remove some of the special elevated permissions that docker demands and might get in the way of a multi

Delete the old containers and install for docker and docker-compose

Official docs: https://docs.docker.com/desktop/uninstall

complete guide incl deleting docker desktop

rm -rf ~/Library/Group\ Containers/group.com.docker rm -rf ~/Library/Containers/com.docker.docker rm -rf ~/.docker

We should also remove ~/.docker/config.json so that we start with a fresh configuration that doesn’t depend on binaries in the Docker Desktop app.

$ rm ~/.docker/config.json

Useful links:

https://marczin.dev/blog/macos-docker-setup/

https://forums.developer.apple.com/forums/thread/718666

https://github.com/abiosoft/colima/issues/734

seanogor commented 1 month ago

cheat sheet can be edited down to fit link, providing more that can be stripped down