mirror of https://github.com/docker/docs.git
Merge pull request #557 from kitematic/opt-in-binaries
Opt-in copying of binaries to /usr/local/bin
This commit is contained in:
commit
f4825a3be9
|
@ -13,7 +13,7 @@ identity*
|
|||
integration
|
||||
|
||||
# Resources
|
||||
resources/docker-*
|
||||
resources/docker*
|
||||
resources/boot2docker-*
|
||||
|
||||
# Cache
|
||||
|
|
|
@ -33,8 +33,6 @@ describe('SetupStore', function () {
|
|||
|
||||
describe('install step', function () {
|
||||
util.exec.mockReturnValue(Promise.resolve());
|
||||
setupUtil.copyBinariesCmd.mockReturnValue(Promise.resolve());
|
||||
setupUtil.fixBinariesCmd.mockReturnValue(Promise.resolve());
|
||||
virtualBox.killall.mockReturnValue(Promise.resolve());
|
||||
setupUtil.installVirtualBoxCmd.mockReturnValue(Promise.resolve());
|
||||
setupUtil.macSudoCmd.mockImplementation(cmd => 'macsudo ' + cmd);
|
||||
|
@ -42,24 +40,11 @@ describe('SetupStore', function () {
|
|||
pit('installs virtualbox if it is not installed', function () {
|
||||
virtualBox.installed.mockReturnValue(false);
|
||||
util.exec.mockReturnValue(Promise.resolve());
|
||||
return setupStore.steps().install.run().then(() => {
|
||||
return setupStore.steps().install.run(() => {}).then(() => {
|
||||
expect(virtualBox.killall).toBeCalled();
|
||||
expect(setupUtil.copyBinariesCmd).toBeCalled();
|
||||
expect(setupUtil.fixBinariesCmd).toBeCalled();
|
||||
expect(setupUtil.installVirtualBoxCmd).toBeCalled();
|
||||
});
|
||||
});
|
||||
|
||||
pit('only installs binaries if virtualbox is installed', function () {
|
||||
virtualBox.installed.mockReturnValue(true);
|
||||
util.compareVersions.mockReturnValue(0);
|
||||
setupUtil.needsBinaryFix.mockReturnValue(true);
|
||||
return setupStore.steps().install.run().then(() => {
|
||||
expect(setupUtil.copyBinariesCmd).toBeCalled();
|
||||
expect(setupUtil.fixBinariesCmd).toBeCalled();
|
||||
expect(setupUtil.installVirtualBoxCmd).not.toBeCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('init step', function () {
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -3,8 +3,10 @@ var app = remote.require('app');
|
|||
var shell = require('shell');
|
||||
var router = require('./router');
|
||||
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
|
||||
|
@ -35,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'
|
||||
|
|
|
@ -37,20 +37,14 @@ var _steps = [{
|
|||
percent: 0,
|
||||
seconds: 5,
|
||||
run: Promise.coroutine(function* (progressCallback) {
|
||||
var cmd = setupUtil.copyBinariesCmd() + ' && ' + setupUtil.fixBinariesCmd();
|
||||
if (!virtualBox.installed()) {
|
||||
yield virtualBox.killall();
|
||||
cmd += ' && ' + setupUtil.installVirtualBoxCmd();
|
||||
} else {
|
||||
if (!setupUtil.needsBinaryFix()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
progressCallback(50); // TODO: detect when the installation has started so we can simulate progress
|
||||
yield util.exec(setupUtil.macSudoCmd(cmd));
|
||||
} catch (err) {
|
||||
throw null;
|
||||
try {
|
||||
yield util.exec(setupUtil.macSudoCmd(setupUtil.installVirtualBoxCmd()));
|
||||
} catch (err) {
|
||||
throw null;
|
||||
}
|
||||
}
|
||||
})
|
||||
}, {
|
||||
|
@ -159,7 +153,7 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), {
|
|||
var vboxNeedsInstall = !virtualBox.installed();
|
||||
|
||||
required.download = vboxNeedsInstall && (!fs.existsSync(vboxfile) || setupUtil.checksum(vboxfile) !== virtualBox.checksum());
|
||||
required.install = vboxNeedsInstall || setupUtil.needsBinaryFix();
|
||||
required.install = vboxNeedsInstall;
|
||||
required.init = required.install || !(yield machine.exists()) || (yield machine.state()) !== 'Running' || !isoversion || util.compareVersions(isoversion, packagejson['docker-version']) < 0;
|
||||
|
||||
var exists = yield machine.exists();
|
||||
|
@ -176,20 +170,10 @@ var SetupStore = assign(Object.create(EventEmitter.prototype), {
|
|||
});
|
||||
return Promise.resolve(_requiredSteps);
|
||||
}),
|
||||
updateBinaries: function () {
|
||||
if (setupUtil.needsBinaryFix()) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (setupUtil.shouldUpdateBinaries()) {
|
||||
return util.exec(setupUtil.copyBinariesCmd());
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
run: Promise.coroutine(function* () {
|
||||
metrics.track('Started Setup', {
|
||||
virtualbox: virtualBox.installed() ? yield virtualBox.version() : 'Not Installed'
|
||||
});
|
||||
yield this.updateBinaries();
|
||||
var steps = yield this.requiredSteps();
|
||||
for (let step of steps) {
|
||||
_currentStep = step;
|
||||
|
|
|
@ -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', ''));
|
||||
});
|
||||
},
|
||||
|
@ -156,7 +156,7 @@ var DockerMachine = {
|
|||
});
|
||||
} 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`];
|
||||
var cmd = [resources.terminal(), `PATH=${resources.resourceDir()}:$PATH 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(() => {});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -12,16 +12,19 @@ var virtualBox = require ('./VirtualBoxUtil');
|
|||
var SetupUtil = {
|
||||
needsBinaryFix() {
|
||||
return this.pathDoesNotExistOrDenied(util.binsPath()) ||
|
||||
this.pathDoesNotExistOrDenied(util.dockerBinPath()) ||
|
||||
this.pathDoesNotExistOrDenied(util.dockerMachineBinPath());
|
||||
(fs.existsSync(util.dockerBinPath()) && this.pathDenied(util.dockerBinPath())) ||
|
||||
(fs.existsSync(util.dockerMachineBinPath()) && this.pathDenied(util.dockerMachineBinPath()));
|
||||
},
|
||||
pathDoesNotExistOrDenied: function (path) {
|
||||
if(util.isWindows()) {
|
||||
return (!fs.existsSync(path));
|
||||
} else {
|
||||
return (!fs.existsSync(path) || fs.statSync(path).gid !== 80 || fs.statSync(path).uid !== process.getuid());
|
||||
return (!fs.existsSync(path) || this.pathDenied(path));
|
||||
}
|
||||
},
|
||||
pathDenied: function (path) {
|
||||
return fs.statSync(path).gid !== 80 || fs.statSync(path).uid !== process.getuid();
|
||||
},
|
||||
shouldUpdateBinaries: function () {
|
||||
return !fs.existsSync(util.dockerBinPath()) ||
|
||||
!fs.existsSync(util.dockerMachineBinPath()) ||
|
||||
|
|
21
util/deps
21
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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue