From 9fafeb38361d5d48e5afc207293715e023b6cfe0 Mon Sep 17 00:00:00 2001 From: Kang Huaishuai Date: Sat, 26 Mar 2022 21:15:46 +0800 Subject: [PATCH] support macos latest docker desktop version --- lib/setup-docker.js | 90 +++++++++++---------------------------------- 1 file changed, 21 insertions(+), 69 deletions(-) diff --git a/lib/setup-docker.js b/lib/setup-docker.js index 034c910..bf3247d 100644 --- a/lib/setup-docker.js +++ b/lib/setup-docker.js @@ -125,12 +125,12 @@ async function run() { core.startGroup('install docker') // await exec.exec('brew', ['update']) - await exec.exec('wget', ['https://raw.githubusercontent.com/Homebrew/homebrew-cask/300b1dcc6d9f61cc93e9351e76066f0846beefe9/Casks/docker.rb']); + // await exec.exec('wget', ['https://raw.githubusercontent.com/Homebrew/homebrew-cask/300b1dcc6d9f61cc93e9351e76066f0846beefe9/Casks/docker.rb']); await exec.exec('brew', [ 'install', '--cask', - // DOCKER_CHANNEL !== 'stable' ? 'docker' : 'docker' - 'docker.rb', + DOCKER_CHANNEL !== 'stable' ? 'docker' : 'docker', + // 'docker.rb', ]); core.endGroup(); @@ -147,78 +147,30 @@ async function run() { ]); core.endGroup(); - // allow the app to run without confirmation - await exec.exec('xattr', [ - '-d', - '-r', - 'com.apple.quarantine', - '/Applications/Docker.app' + core.startGroup('start docker step1'); + // https://github.com/docker/for-mac/issues/2359#issuecomment-943131345 + await exec.exec('sudo',[ + '/Applications/Docker.app/Contents/MacOS/Docker', + '--unattended', + '--install-privileged-components' ]); - - // preemptively do docker.app's setup to avoid any gui prompts - core.startGroup('start docker'); + core.endGroup(); + core.startGroup('start docker step2'); + await exec.exec('open',[ + '-a', + '/Applications/Docker.app', + '--args', + '--unattended', + '--accept-license' + ]); + core.endGroup(); + core.startGroup('wait docker running'); await exec.exec('sudo', [ 'bash', '-c', ` set -x - -VmnetdVersion=$(cat /Applications/Docker.app/Contents/Info.plist | tail -5 | head -1 | cut -d '>' -f 2 | cut -d '<' -f 1) - -cat < - - - - Label - com.docker.vmnetd - Program - /Library/PrivilegedHelperTools/com.docker.vmnetd - ProgramArguments - - /Library/PrivilegedHelperTools/com.docker.vmnetd - - RunAtLoad - - Sockets - - Listener - - SockPathMode - 438 - SockPathName - /var/run/com.docker.vmnetd.sock - - - Version - \${VmnetdVersion} - - -EOF - -sudo /bin/cp /Applications/Docker.app/Contents/Library/LaunchServices/com.docker.vmnetd /Library/PrivilegedHelperTools -# sudo /bin/cp /Applications/Docker.app/Contents/Resources/com.docker.vmnetd.plist /Library/LaunchDaemons/ -sudo /bin/cp /tmp/com.docker.vmnetd.plist /Library/LaunchDaemons/ -sudo /bin/chmod 544 /Library/PrivilegedHelperTools/com.docker.vmnetd -sudo /bin/chmod 644 /Library/LaunchDaemons/com.docker.vmnetd.plist -sudo /bin/launchctl load /Library/LaunchDaemons/com.docker.vmnetd.plist -open -g /Applications/Docker.app || exit - -sleep 60 - -docker info > /dev/null || true - -sleep 30 - -docker info > /dev/null || true -# Wait for the server to start up, if applicable. -i=0 -while ! docker system info &>/dev/null; do -(( i++ == 0 )) && printf %s '-- Waiting for Docker to finish starting up...' || printf '.' -sleep 1 -done -(( i )) && printf '\n' - +while ! /Applications/Docker.app/Contents/Resources/bin/docker info &>/dev/null; do sleep 1;done echo "-- Docker is ready." `]); core.endGroup();