Skip to content

Commit

Permalink
support macos latest docker desktop version
Browse files Browse the repository at this point in the history
  • Loading branch information
khs1994 authored Mar 26, 2022
1 parent e2e6958 commit 9fafeb3
Showing 1 changed file with 21 additions and 69 deletions.
90 changes: 21 additions & 69 deletions lib/setup-docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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 <<EOF | tee /tmp/com.docker.vmnetd.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.docker.vmnetd</string>
<key>Program</key>
<string>/Library/PrivilegedHelperTools/com.docker.vmnetd</string>
<key>ProgramArguments</key>
<array>
<string>/Library/PrivilegedHelperTools/com.docker.vmnetd</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>Sockets</key>
<dict>
<key>Listener</key>
<dict>
<key>SockPathMode</key>
<integer>438</integer>
<key>SockPathName</key>
<string>/var/run/com.docker.vmnetd.sock</string>
</dict>
</dict>
<key>Version</key>
<string>\${VmnetdVersion}</string>
</dict>
</plist>
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();
Expand Down

0 comments on commit 9fafeb3

Please sign in to comment.