From d58b6779dbeb3f71d6f712911e468c9b43993f00 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Wed, 27 May 2015 18:28:40 -0700 Subject: [PATCH] Docker-machine 0.3.0 RC with optional binaries --- .gitignore | 2 +- package.json | 2 +- src/menutemplate.js | 39 +++++++++++++++++----------------- src/utils/DockerMachineUtil.js | 2 +- src/utils/DockerUtil.js | 4 +++- src/utils/ResourcesUtil.js | 4 ++-- util/deps | 21 +++++++++--------- util/deps.ps1 | 16 ++++++-------- 8 files changed, 46 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 3b0964fe..e51ebc54 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ identity* integration # Resources -resources/docker-* +resources/docker* resources/boot2docker-* # Cache diff --git a/package.json b/package.json index 25ce4dd1..c8fe0c52 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ } ], "docker-version": "1.6.2", - "docker-machine-version": "0.2.0", + "docker-machine-version": "0.3.0", "electron-version": "0.26.0", "virtualbox-version": "4.3.28", "virtualbox-filename": "VirtualBox-4.3.28.pkg", diff --git a/src/menutemplate.js b/src/menutemplate.js index 36d5b446..4e10b5ae 100644 --- a/src/menutemplate.js +++ b/src/menutemplate.js @@ -6,6 +6,7 @@ var util = require('./utils/Util'); var setupUtil = require('./utils/SetupUtil'); var metrics = require('./utils/MetricsUtil'); var machine = require('./utils/DockerMachineUtil'); +var dialog = remote.require('dialog'); import docker from './utils/DockerUtil'; // main.js @@ -21,23 +22,6 @@ var MenuTemplate = function () { { type: 'separator' }, - { - label: 'Install Docker Commands', - enabled: true, - click: function () { - metrics.track('Installed Docker Commands'); - if (!setupUtil.shouldUpdateBinaries()) { - return; - } - - if (setupUtil.needsBinaryFix()) { - let cmd = setupUtil.copyBinariesCmd() + ' && ' + setupUtil.fixBinariesCmd(); - util.exec(setupUtil.macSudoCmd(cmd)).catch(() => {}); - } else { - util.exec(setupUtil.copyBinariesCmd()); - } - }, - }, { label: 'Preferences', accelerator: util.CommandOrCtrl() + '+,', @@ -53,8 +37,25 @@ var MenuTemplate = function () { type: 'separator' }, { - label: 'Services', - submenu: [] + label: 'Install Docker Commands', + enabled: true, + click: function () { + metrics.track('Installed Docker Commands'); + if (!setupUtil.shouldUpdateBinaries()) { + return; + } + + let copy = setupUtil.needsBinaryFix() ? + util.exec(setupUtil.copyBinariesCmd() + ' && ' + setupUtil.fixBinariesCmd()) : + util.exec(setupUtil.copyBinariesCmd()); + + copy.then(() => { + dialog.showMessageBox({ + message: 'Docker Binaries have been copied to /usr/local/bin', + buttons: ['OK'] + }); + }).catch(() => {}); + }, }, { type: 'separator' diff --git a/src/utils/DockerMachineUtil.js b/src/utils/DockerMachineUtil.js index b5dceb62..3e52871d 100644 --- a/src/utils/DockerMachineUtil.js +++ b/src/utils/DockerMachineUtil.js @@ -72,7 +72,7 @@ var DockerMachine = { return util.exec([this.command(), 'rm', '-f', NAME]); }, ip: function () { - return util.exec([this.command(), '-D', 'ip', NAME]).then(stdout => { + return util.exec([this.command(), 'ip', NAME]).then(stdout => { return Promise.resolve(stdout.trim().replace('\n', '')); }); }, diff --git a/src/utils/DockerUtil.js b/src/utils/DockerUtil.js index 0ec52f08..1109a381 100644 --- a/src/utils/DockerUtil.js +++ b/src/utils/DockerUtil.js @@ -17,7 +17,7 @@ export default { setup (ip, name) { if (!ip || !name) { - throw new Error('Falsy ip or machine name passed to init'); + throw new Error('Falsy ip or name passed to docker client setup'); } let certDir = path.join(util.home(), '.docker/machine/machines/', name); @@ -25,6 +25,8 @@ export default { throw new Error('Certificate directory does not exist'); } + console.log(ip); + this.host = ip; this.client = new dockerode({ protocol: 'https', diff --git a/src/utils/ResourcesUtil.js b/src/utils/ResourcesUtil.js index 0c170db7..9459db8f 100644 --- a/src/utils/ResourcesUtil.js +++ b/src/utils/ResourcesUtil.js @@ -12,9 +12,9 @@ module.exports = { return path.join(this.resourceDir(), 'terminal'); }, docker: function () { - return path.join(this.resourceDir(), 'docker-' + util.packagejson()['docker-version'] + util.binsEnding()); + return path.join(this.resourceDir(), 'docker' + util.binsEnding()); }, dockerMachine: function () { - return path.join(this.resourceDir(), 'docker-machine-' + util.packagejson()['docker-machine-version'] + util.binsEnding()); + return path.join(this.resourceDir(), 'docker-machine' + util.binsEnding()); } }; diff --git a/util/deps b/util/deps index fc06cb50..25afdbb1 100755 --- a/util/deps +++ b/util/deps @@ -1,29 +1,30 @@ #!/bin/bash DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" BASE=$DIR/.. -DOCKER_MACHINE_CLI_VERSION=$(node -pe "JSON.parse(process.argv[1])['docker-machine-version']" "$(cat $BASE/package.json)") -DOCKER_MACHINE_CLI_FILE=docker-machine-$DOCKER_MACHINE_CLI_VERSION DOCKER_VERSION=$(node -pe "JSON.parse(process.argv[1])['docker-version']" "$(cat $BASE/package.json)") -DOCKER_CLI_FILE=docker-$DOCKER_VERSION +DOCKER_MACHINE_VERSION=$(node -pe "JSON.parse(process.argv[1])['docker-machine-version']" "$(cat $BASE/package.json)") +CURRENT_DOCKER_VERSION=$($BASE/resources/docker -v | cut -d ',' -f1 | awk '{print $3}' | cut -d '-' -f1) +CURRENT_DOCKER_MACHINE_VERSION=$($BASE/resources/docker-machine -v | cut -d ',' -f1 | awk '{print $3}' | cut -d '-' -f1) BOOT2DOCKER_FILE=boot2docker-$DOCKER_VERSION.iso pushd $BASE/resources > /dev/null -if [ ! -f $DOCKER_CLI_FILE ]; then +if [ "$DOCKER_VERSION" != "$CURRENT_DOCKER_VERSION" ]; then echo "-----> Downloading Docker CLI..." + rm -rf docker rm -rf docker-* curl -L -o docker-$DOCKER_VERSION.tgz https://get.docker.com/builds/Darwin/x86_64/docker-$DOCKER_VERSION.tgz tar xvzf docker-$DOCKER_VERSION.tgz --strip=3 rm docker-$DOCKER_VERSION.tgz - mv docker docker-$DOCKER_VERSION - chmod +x $DOCKER_VERSION + chmod +x docker fi -if [ ! -f $DOCKER_MACHINE_CLI_FILE ]; then +if [ "$DOCKER_MACHINE_VERSION" != "$CURRENT_DOCKER_MACHINE_VERSION" ]; then echo "-----> Downloading Docker Machine CLI..." - rm -rf docker-machine* - curl -L -o $DOCKER_MACHINE_CLI_FILE https://github.com/docker/machine/releases/download/v$DOCKER_MACHINE_CLI_VERSION/docker-machine_darwin-amd64 - chmod +x $DOCKER_MACHINE_CLI_FILE + rm -rf docker-machine + rm -rf docker-machine-* + curl -L -o docker-machine https://github.com/docker/machine/releases/download/v$DOCKER_MACHINE_VERSION-rc1/docker-machine_darwin-amd64 + chmod +x docker-machine fi if [ ! -f $BOOT2DOCKER_FILE ]; then diff --git a/util/deps.ps1 b/util/deps.ps1 index caf5f198..ba08d6c2 100644 --- a/util/deps.ps1 +++ b/util/deps.ps1 @@ -8,21 +8,19 @@ $packageJsonContent = $serializer.DeserializeObject($packageJson) $webclient = New-Object System.Net.WebClient $DOCKER_MACHINE_CLI_VERSION = $packageJsonContent['docker-machine-version'] -$DOCKER_MACHINE_CLI_FILE = 'docker-machine-' + $DOCKER_MACHINE_CLI_VERSION + '.exe' $DOCKER_CLI_VERSION = $packageJsonContent['docker-version'] -$DOCKER_CLI_FILE = 'docker-' + $DOCKER_CLI_VERSION + '.exe' -if(-Not (test-path ($BasePath + '\resources\' + $DOCKER_CLI_FILE))) { +if(-Not (test-path ($BasePath + '\resources\docker'))) { echo "-----> Downloading Docker CLI..." $source = "https://master.dockerproject.com/windows/amd64/docker.exe" - $destination = $BasePath + "\resources\" + $DOCKER_CLI_FILE + $destination = $BasePath + "\resources\docker" $webclient.DownloadFile($source, $destination) } -if(-Not (test-path ($BasePath + '\resources\' + $DOCKER_MACHINE_CLI_FILE))) { - echo "-----> Downloading Docker Machine CLI..." - $source = "https://github.com/docker/machine/releases/download/v0.1.0/docker-machine_windows-amd64.exe" - $destination = $BasePath + "\resources\" + $DOCKER_MACHINE_CLI_FILE +if(-Not (test-path ($BasePath + '\resources\docker-machine'))) { + echo "-----> Downloading Docker Machine CLI..." + $source = "https://github.com/docker/machine/releases/download/v" + $DOCKER_MACHINE_VERSION+ "/docker-machine_windows-amd64.exe" + $destination = $BasePath + "\resources\docker-machine" $webclient.DownloadFile($source, $destination) -} \ No newline at end of file +}