Fixing any breaks from Docker 1.3

This commit is contained in:
Jeff Morgan 2014-10-19 16:28:53 -07:00
parent 71efa76911
commit c10ecc54db
7 changed files with 57 additions and 43 deletions

View File

@ -7,7 +7,7 @@ Boot2Docker = {};
Boot2Docker.REQUIRED_IP = '192.168.60.103';
Boot2Docker.command = function () {
return path.join(Util.getBinDir().replace(' ', '\\ '), 'boot2docker-1.2.0') + ' --vm="kitematic-vm"';
return path.join(Util.getBinDir().replace(' ', '\\ '), 'boot2docker-1.3.0') + ' --vm="kitematic-vm"';
};
Boot2Docker.exec = function (command, callback) {
@ -60,8 +60,12 @@ Boot2Docker.ip = function (callback) {
};
Boot2Docker.setIp = function (ifname, ip, callback) {
this.exec('ssh "sudo ifconfig ' + ifname + ' ' + ip + ' netmask 255.255.255.0"', function (err, stdout) {
callback(err);
Boot2Docker.exec('ssh "sudo ifconfig ' + ifname + ' ' + ip + ' netmask 255.255.255.0"', function (err, stdout) {
Boot2Docker.exec('ssh "sudo awk \'{print $0 \",192.168.60.103\"}\' /var/lib/boot2docker/tls/hostnames > temp && sudo mv temp /var/lib/boot2docker/tls/hostnames && sudo chown root.root /var/lib/boot2docker/tls', function (err, stdout) {
Boot2Docker.exec('ssh "sudo /usr/local/etc/init.d/docker restart"', function (err, stdout) {
callback(err);
});
});
});
};
@ -78,10 +82,10 @@ Boot2Docker.start = function (callback) {
callback('Cannot start if the boot2docker VM doesn\'t exist');
return;
}
self.exec('up -v', function (err, stdout) {
self.exec('start', function (err, stdout) {
// Sometimes boot2docker returns an error code even though it's working / waiting, so treat that as
// Success as well
if (!err || (err.indexOf('Waiting for VM to be started') !== -1 || err.indexOf('..........') !== -1)) {
if (!err || (err.indexOf('Waiting') !== -1 || err.indexOf('Writing') !== -1)) {
self.correct(function (err) {
if (err) { callback(err); return; }
self.injectUtilities(function (err) {
@ -96,7 +100,7 @@ Boot2Docker.start = function (callback) {
};
Boot2Docker.correct = function (callback) {
Boot2Docker.setIp('eth2', Boot2Docker.REQUIRED_IP, function(err) {
Boot2Docker.setIp('eth1', Boot2Docker.REQUIRED_IP, function(err) {
if (err) { callback(err); return; }
VirtualBox.removeDHCP(function (err) {
callback();
@ -239,7 +243,7 @@ Boot2Docker.version = function (callback) {
};
Boot2Docker.injectUtilities = function (callback) {
exec('/bin/cat ' + path.join(Util.getBinDir(), 'kite-binaries.tar.gz') + ' | ' + Boot2Docker.command() + ' ssh "tar zx -C /usr/local/bin"', function (err, stdout) {
exec('/bin/cat ' + path.join(Util.getBinDir(), 'kite-binaries.tar.gz') + ' | ' + Boot2Docker.command() + ' ssh "sudo tar zx -C /usr/local/bin && sudo chown -R root.root /usr/local/bin"', function (err, stdout) {
callback(err);
});
};

View File

@ -2,15 +2,24 @@ var Dockerode = require('dockerode');
var async = require('async');
var exec = require('exec');
var path = require('path');
var fs = require('fs');
Docker = {};
Docker.DOCKER_HOST = '192.168.60.103';
Docker.DEFAULT_IMAGES_FILENAME = 'base-images-0.0.2.tar.gz';
Docker.DEFAULT_IMAGES_CHECKSUM = 'a3517ac21034a1969d9ff15e3c41b1e2f1aa83c67b16a8bd0bc378ffefaf573b'; // Sha256 Checksum
Docker.CERT_DIR = path.join(process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME'], '.boot2docker/certs/kitematic-vm');
Docker.HOST_IP = '192.168.60.103';
Docker.HOST_PORT = '2376';
Docker.client = function () {
return new Dockerode({host: Docker.DOCKER_HOST, port: '2375'});
return new Dockerode({
host: Docker.HOST_IP,
port: Docker.HOST_PORT,
ca: fs.readFileSync(path.join(Docker.CERT_DIR, 'ca.pem')),
cert: fs.readFileSync(path.join(Docker.CERT_DIR, 'cert.pem')),
key: fs.readFileSync(path.join(Docker.CERT_DIR, 'key.pem'))
});
};
var docker = Docker.client();

View File

@ -38,7 +38,6 @@ Installer.steps = [
progressCallback(progress);
});
} else {
// Version 4.3.12 is required.
VirtualBox.version(function (err, installedVersion) {
if (err) {callback(err); return;}
if (Util.compareVersions(installedVersion, VirtualBox.REQUIRED_VERSION) < 0) {
@ -65,7 +64,7 @@ Installer.steps = [
});
}
},
pastMessage: 'VirtualBox installed',
pastMessage: 'VirtualBox Installed',
message: 'Downloading & Installing VirtualBox',
futureMessage: 'Download & Install VirtualBox if necessary'
},
@ -76,7 +75,7 @@ Installer.steps = [
Boot2Docker.exists(function (err, exists) {
if (err) { callback(err); return; }
if (!exists) {
var vmFilesPath = path.join(Util.getHomePath(), 'VirtualBox VMs', 'kitematic-vm');
var vmFilesPath = path.join(Util.getHomePath(), 'VirtualBox\ VMs', 'kitematic-vm');
if (fs.existsSync(vmFilesPath)) {
Util.deleteFolder(vmFilesPath);
}
@ -92,7 +91,7 @@ Installer.steps = [
callback(err);
});
});
}
}
}
});
},
@ -123,7 +122,7 @@ Installer.steps = [
callback(err);
});
} else {
Boot2Docker.setIp('eth2', Boot2Docker.REQUIRED_IP, function(err) {
Boot2Docker.setIp('eth1', Boot2Docker.REQUIRED_IP, function(err) {
callback(err);
});
}

View File

@ -4,10 +4,10 @@ var path = require('path');
VirtualBox = {};
VirtualBox.REQUIRED_VERSION = '4.3.14';
VirtualBox.INCLUDED_VERSION = '4.3.14';
VirtualBox.INSTALLER_FILENAME = 'virtualbox-4.3.14.pkg';
VirtualBox.INSTALLER_CHECKSUM = '486348a5336539728ca20dcd9674cf3d37e5c7f32255d90f1edc7391b54bd5dd'; // Sha256 Checksum
VirtualBox.REQUIRED_VERSION = '4.3.18';
VirtualBox.INCLUDED_VERSION = '4.3.18';
VirtualBox.INSTALLER_FILENAME = 'virtualbox-4.3.18.pkg';
VirtualBox.INSTALLER_CHECKSUM = '5836c94481c460c648b9216386591a2915293ac86b9bb6c57746637796af6af2'; // Sha256 Checksum
// Info for the hostonly interface we add to the VM.
VirtualBox.HOSTONLY_HOSTIP = '192.168.60.3';
@ -129,7 +129,7 @@ VirtualBox.addCustomHostAdapter = function (vm, callback) {
var self = this;
self.hostOnlyAdapter(function (err, ifname) {
if (err) { callback(err); return; }
self.exec('modifyvm ' + vm + ' --nic3 hostonly --nictype3 virtio --cableconnected3 on --hostonlyadapter3 ' + ifname, function (err, stdout, stderr) {
self.exec('modifyvm ' + vm + ' --nic2 hostonly --nictype2 virtio --cableconnected2 on --hostonlyadapter2 ' + ifname, function (err, stdout, stderr) {
callback(err, ifname);
});
});

View File

@ -124,24 +124,26 @@ var fixDefaultContainers = function (callback) {
};
Meteor.setInterval(function () {
Boot2Docker.exists(function (err, exists) {
if (err) { console.log(err); return; }
if (exists) {
Boot2Docker.state(function (err, state) {
if (err) { console.log(err); return; }
Session.set('boot2dockerState', state);
if (state === 'running') {
Boot2Docker.stats(function (err, stats) {
if (err) { console.log(err); return; }
if (stats.state !== 'poweroff' && stats.memory && stats.disk) {
Session.set('boot2dockerMemoryUsage', stats.memory);
Session.set('boot2dockerDiskUsage', stats.disk);
}
});
}
});
}
});
if (!Session.get('installing')) {
Boot2Docker.exists(function (err, exists) {
if (err) { console.log(err); return; }
if (exists) {
Boot2Docker.state(function (err, state) {
if (err) { console.log(err); return; }
Session.set('boot2dockerState', state);
if (state === 'running') {
Boot2Docker.stats(function (err, stats) {
if (err) { console.log(err); return; }
if (stats.state !== 'poweroff' && stats.memory && stats.disk) {
Session.set('boot2dockerMemoryUsage', stats.memory);
Session.set('boot2dockerDiskUsage', stats.disk);
}
});
}
});
}
});
}
}, 5000);
Meteor.setInterval(function () {

View File

@ -3,16 +3,16 @@
"main": "index.js",
"version": "0.2.3",
"dependencies": {
"ansi-to-html": "0.2.0",
"async": "^0.9.0",
"chokidar": "git+https://github.com/usekite/chokidar.git",
"dockerode": "2.0.3",
"exec": "^0.1.2",
"moment": "2.8.1",
"ncp": "0.6.0",
"open": "0.0.5",
"dockerode": "2.0.3",
"tar": "0.1.20",
"ansi-to-html": "0.2.0",
"request": "2.42.0",
"request-progress": "0.3.1",
"ncp": "0.6.0"
"tar": "0.1.20"
}
}

View File

@ -11,7 +11,7 @@ mkdir -p cache
pushd cache
BOOT2DOCKER_CLI_VERSION=1.2.0
BOOT2DOCKER_CLI_VERSION=1.3.0
BOOT2DOCKER_CLI_VERSION_FILE=boot2docker-$BOOT2DOCKER_CLI_VERSION
BOOT2DOCKER_CLI_FILE=boot2docker
@ -54,7 +54,7 @@ pushd resources
if [ ! -f $BOOT2DOCKER_CLI_VERSION_FILE ]; then
cecho "-----> Downloading Boot2docker CLI..." $purple
curl -L -o $BOOT2DOCKER_CLI_VERSION_FILE https://s3.amazonaws.com/kite-installer/boot2docker-v$BOOT2DOCKER_CLI_VERSION
curl -L -o $BOOT2DOCKER_CLI_VERSION_FILE https://github.com/boot2docker/boot2docker-cli/releases/download/v${BOOT2DOCKER_CLI_VERSION}/boot2docker-v${BOOT2DOCKER_CLI_VERSION}-darwin-amd64
fi
chmod +x $BOOT2DOCKER_CLI_VERSION_FILE