mirror of
https://github.com/docker/docs.git
synced 2026-11-06 12:54:24 +03:00
- For now changes in SetupStore are made, to skip steps that do MacOS setup. - Adding deps.ps1 script for installing all required dependencies on windows. - Adding reset.ps1 script for removing all dependencies on windows. - Modifying files to work with windows dependencies - Fix for duplicate react instances in the code. - A fix required to load only one instance of React in the application. Without such fix, on windows application loads two instances of React at start time, and crashes. - Modifying files to support windows paths - Modifying deps and reset powershell scripts to loose chocolatey dependency. Adding windows VirtualBox installation steps. - Improved a workaround for adding Users directory to the shared folder in the VM on windows. Added few more fixes for Windows/Mac compatibility. - Removing unnecessary log from deps.ps1 script, - Updating Gulpfile to download and copy all the dependencies on application start, - Cleaning pre and post install scripts from package.json, as they are not realy friendly for different platforms. - Removing changes from browser.js as they were not necessary or even breaking. - Cleaning pre and post install scripts from package.json, as they are not really friendly for different platforms. - Fixing changes in package.json. - Fixed reset.ps1 file to delete all folders created by the app, - Fixed metrics.js file to properly use userAgent depending on the OS. - Uncommented updateBinaries line in SetupStore. - Adding open as a dependency. - Fixing the setupStore tests. - Adding proper directory to PATH for docker and docker-machine binaries. - Adding support for the docker terminal command. It opens a CMD on windows and sets required env variables for the docker to work. Docker and Docker-Machine should be on the path, as they are set up there on Kitematic startup. - Added Resources module which provides paths to all files stored in the resources directory, - Added docker and docker-machine binary paths to Util module, to have a single place for calling those paths, - Added binaries directory path, to Util module, to have a single place for calling this path, - Added another exec command, which utilizes "child_process" module, and it's "exec" command, as the "exec" used right now is deprecated, - Refactored the Installation step in the SetupStore, and connected with that SetupUtil commands to perform copying binaries from node instead of bash commands. That way application is more cross-platform friendly, - Added new dependencies in form of fs-extra, fs-promise and any-promise, to allow yielding of fs commands in SetupUtil. - The setup process now works correctly on windows from the beginning to end. - Fixing broken tests. - Improving tests. - Adding elevated permissions to the reset script, as it is required to kill processes and remove VirtualBox. - Added ability to run reset scripts through gulp, - Added new npm script for resetting the environment "npm run reset". - Refactored docker-machine module, to use Resources module for finding the machine command and general code cleaning, - Added windows keyboard shortcut support. - Adding the use of Resources module, instead of direct access of files in the resources dir. - Testing appveyor. - Testing appveyor + io.js. - Back to node 0.10. - Fixing permission issues with appveyor. - Testing travis. Signed-off-by: Dominik Deren <dominik.deren@live.com> - Working on changes required to setup client on windows. - For now changes in SetupStore are made, to skip steps that do MacOS setup. - Adding deps.ps1 script for installing all required dependencies on windows. - Adding reset.ps1 script for removing all dependencies on windows. Fix for duplicate react instances in the code. Modifying files to support windows paths - Removing unnecessary log from deps.ps1 script, - Updating Gulpfile to download and copy all the dependencies on application start, - Cleaning pre and post install scripts from package.json, as they are not realy friendly for different platforms. - Removing changes from browser.js as they were not necessary or even breaking. - Fixing changes in package.json. - Uncommented updateBinaries line in SetupStore. - Adding open as a dependency. - Adding proper directory to PATH for docker and docker-machine binaries. - Fixing broken tests. - Improving tests. - Adding elevated permissions to the reset script, as it is required to kill processes and remove VirtualBox. - Added ability to run reset scripts through gulp, - Added new npm script for resetting the environment "npm run reset". - Refactored docker-machine module, to use Resources module for finding the machine command and general code cleaning, - Added windows keyboard shortcut support. - Adding the use of Resources module, instead of direct access of files in the resources dir. - Testing appveyor + io.js. - Back to node 0.10. - Fixing permission issues with appveyor. Signed-off-by: Dominik Deren <dominik.deren@live.com>
168 lines
4.8 KiB
JavaScript
168 lines
4.8 KiB
JavaScript
var _ = require('underscore');
|
|
var path = require('path');
|
|
var Promise = require('bluebird');
|
|
var fs = require('fs');
|
|
var util = require('./Util');
|
|
var exec = require('child_process').exec;
|
|
var resources = require('./Resources');
|
|
|
|
var NAME = 'dev';
|
|
|
|
var DockerMachine = {
|
|
command() {
|
|
return resources.docker_machine();
|
|
},
|
|
name() {
|
|
return NAME;
|
|
},
|
|
isoversion() {
|
|
try {
|
|
var data = fs.readFileSync(path.join(util.home(), '.docker', 'machine', 'machines', NAME, 'boot2docker.iso'), 'utf8');
|
|
var match = data.match(/Boot2Docker-v(\d+\.\d+\.\d+)/);
|
|
if (match) {
|
|
return match[1];
|
|
} else {
|
|
return null;
|
|
}
|
|
} catch (err) {
|
|
return null;
|
|
}
|
|
},
|
|
info() {
|
|
return util.exec([this.command(), 'ls']).then(stdout => {
|
|
var lines = stdout.trim().split('\n').filter(line => line.indexOf('time=') === -1);
|
|
var machines = {};
|
|
lines.slice(1, lines.length).forEach(line => {
|
|
var tokens = line.trim().split(/[\s]+/).filter(token => token !== '*');
|
|
var machine = {
|
|
name: tokens[0],
|
|
driver: tokens[1],
|
|
state: tokens[2],
|
|
url: tokens[3] || ''
|
|
};
|
|
machines[machine.name] = machine;
|
|
});
|
|
if (machines[NAME]) {
|
|
return machines[NAME];
|
|
} else {
|
|
throw new Error('Machine does not exist.');
|
|
}
|
|
});
|
|
},
|
|
exists() {
|
|
return this.info().then(() => {
|
|
return true;
|
|
}).catch(() => {
|
|
return false;
|
|
});
|
|
},
|
|
|
|
create() {
|
|
return util.exec([this.command(), 'create', '-d', 'virtualbox', '--virtualbox-memory', '2048', NAME]);
|
|
},
|
|
start() {
|
|
return util.exec([this.command(), 'start', NAME]);
|
|
},
|
|
stop() {
|
|
return util.exec([this.command(), 'stop', NAME]);
|
|
},
|
|
upgrade() {
|
|
return util.exec([this.command(), 'upgrade', NAME]);
|
|
},
|
|
rm() {
|
|
return util.exec([this.command(), 'rm', '-f', NAME]);
|
|
},
|
|
ip() {
|
|
return util.exec([this.command(), 'ip', NAME]).then(stdout => {
|
|
return Promise.resolve(stdout.trim().replace('\n', ''));
|
|
});
|
|
},
|
|
regenerateCerts() {
|
|
return util.exec([this.command(), 'tls-regenerate-certs', '-f', NAME]);
|
|
},
|
|
state() {
|
|
return this.info().then(info => {
|
|
return info ? info.state : null;
|
|
});
|
|
},
|
|
disk() {
|
|
return util.exec([this.command(), 'ssh', NAME, 'df']).then(stdout => {
|
|
try {
|
|
var lines = stdout.split('\n');
|
|
var dataline = _.find(lines, function (line) {
|
|
return line.indexOf('/dev/sda1') !== -1;
|
|
});
|
|
var tokens = dataline.split(' ');
|
|
tokens = tokens.filter(function (token) {
|
|
return token !== '';
|
|
});
|
|
var usedGb = parseInt(tokens[2], 10) / 1000000;
|
|
var totalGb = parseInt(tokens[3], 10) / 1000000;
|
|
var percent = parseInt(tokens[4].replace('%', ''), 10);
|
|
return {
|
|
used_gb: usedGb.toFixed(2),
|
|
total_gb: totalGb.toFixed(2),
|
|
percent: percent
|
|
};
|
|
} catch (err) {
|
|
return Promise.reject(err);
|
|
}
|
|
});
|
|
},
|
|
memory() {
|
|
return util.exec([this.command(), 'ssh', NAME, 'free -m']).then(stdout => {
|
|
try {
|
|
var lines = stdout.split('\n');
|
|
var dataline = _.find(lines, function (line) {
|
|
return line.indexOf('-/+ buffers') !== -1;
|
|
});
|
|
var tokens = dataline.split(' ');
|
|
tokens = tokens.filter(function(token) {
|
|
return token !== '';
|
|
});
|
|
var usedGb = parseInt(tokens[2], 10) / 1000;
|
|
var freeGb = parseInt(tokens[3], 10) / 1000;
|
|
var totalGb = usedGb + freeGb;
|
|
var percent = Math.round(usedGb / totalGb * 100);
|
|
return {
|
|
used_gb: usedGb.toFixed(2),
|
|
total_gb: totalGb.toFixed(2),
|
|
free_gb: freeGb.toFixed(2),
|
|
percent: percent
|
|
};
|
|
} catch (err) {
|
|
return Promise.reject(err);
|
|
}
|
|
});
|
|
},
|
|
stats() {
|
|
this.state().then(state => {
|
|
if (state === 'Stopped') {
|
|
return Promise.resolve({state: state});
|
|
}
|
|
var memory = this.memory();
|
|
var disk = this.disk();
|
|
return Promise.all([memory, disk]).spread((memory, disk) => {
|
|
return Promise.resolve({
|
|
memory: memory,
|
|
disk: disk
|
|
});
|
|
});
|
|
});
|
|
},
|
|
dockerTerminal() {
|
|
if(util.isWindows()) {
|
|
this.info().then(machine => {
|
|
util.execProper(`start cmd.exe /k "SET DOCKER_HOST=${machine.url}&& SET DOCKER_CERT_PATH=${path.join(util.home(), '.docker/machine/machines/' + machine.name)}&& SET DOCKER_TLS_VERIFY=1`);
|
|
});
|
|
} else {
|
|
this.info().then(machine => {
|
|
var cmd = [resources.terminal(), `DOCKER_HOST=${machine.url} DOCKER_CERT_PATH=${path.join(util.home(), '.docker/machine/machines/' + machine.name)} DOCKER_TLS_VERIFY=1 $SHELL`];
|
|
util.exec(cmd).then(() => {});
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = DockerMachine;
|