mirror of https://github.com/docker/docs.git
Move binary download code to gulp
This commit is contained in:
parent
7b507067e9
commit
ce2452bffd
95
gulpfile.js
95
gulpfile.js
|
|
@ -14,6 +14,9 @@ var plumber = require('gulp-plumber');
|
|||
var runSequence = require('run-sequence');
|
||||
var shell = require('gulp-shell');
|
||||
var sourcemaps = require('gulp-sourcemaps');
|
||||
var execFile = require('child_process').execFile;
|
||||
var request = require('request');
|
||||
var path = require('path');
|
||||
|
||||
var dependencies = Object.keys(packagejson.dependencies);
|
||||
var argv = require('minimist')(process.argv.slice(2));
|
||||
|
|
@ -175,16 +178,86 @@ gulp.task('settings', function () {
|
|||
string_src('settings.json', JSON.stringify(settings)).pipe(gulp.dest('dist/osx/' + options.appFilename.replace(' ', '\ ').replace('(','\(').replace(')','\)') + '/Contents/Resources/app'));
|
||||
});
|
||||
|
||||
gulp.task('download-deps', function () {
|
||||
if(process.platform === 'win32') {
|
||||
return gulp.src('').pipe(
|
||||
shell(['powershell.exe -ExecutionPolicy unrestricted -File util\\deps.ps1'])
|
||||
);
|
||||
} else {
|
||||
return gulp.src('').pipe(
|
||||
shell(['./util/deps'])
|
||||
);
|
||||
var version = function (str) {
|
||||
var match = str.match(/(\d+\.\d+\.\d+)/);
|
||||
if (match) {
|
||||
return match[1];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
gulp.task('download-docker', function (cb) {
|
||||
if (process.platform === 'win32' && fs.existsSync(path.join('resources', 'docker.exe'))) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
execFile(path.join('resources', 'docker'), ['-v'], function (err, stdout, stderr) {
|
||||
var currentVersion = version(stdout);
|
||||
if (currentVersion && currentVersion === packagejson['docker-version']) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
gutil.log(gutil.colors.green('Downloading Docker'));
|
||||
|
||||
if(process.platform === 'win32') {
|
||||
request('https://master.dockerproject.com/windows/amd64/docker-1.7.0-dev.exe').pipe(fs.createWriteStream('./resources/docker.exe')).on('end', cb);
|
||||
} else {
|
||||
request('https://get.docker.com/builds/Darwin/x86_64/docker-' + packagejson['docker-version'] + '.tgz').pipe(fs.createWriteStream('./resources/docker')).on('end', cb);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('download-docker-machine', function (cb) {
|
||||
execFile(path.join('resources', 'docker-machine'), ['-v'], function (err, stdout, stderr) {
|
||||
var currentVersion = version(stdout);
|
||||
if (currentVersion && currentVersion === version(packagejson['docker-machine-version'])) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
gutil.log(gutil.colors.green('Downloading Docker Machine'));
|
||||
|
||||
if(process.platform === 'win32') {
|
||||
request('https://github.com/docker/machine/releases/download/v' + packagejson['docker-machine-version'] + '/docker-machine_windows-amd64.exe')
|
||||
.pipe(fs.createWriteStream('./resources/docker-machine.exe')).on('end', function () {cb()});
|
||||
} else {
|
||||
request('https://github.com/docker/machine/releases/download/v' + packagejson['docker-machine-version'] + 'docker-machine_darwin-amd64')
|
||||
.pipe(fs.createWriteStream('./resources/docker-machine')).on('end', function () {cb()});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('download-docker-compose', function (cb) {
|
||||
execFile(path.join('resources', 'docker-compose'), ['--version'], function (err, stdout, stderr) {
|
||||
var currentVersion = version(stdout);
|
||||
if (currentVersion && currentVersion === packagejson['docker-compose-version']) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
if(process.platform === 'win32') {
|
||||
// Todo: install windows version of compose
|
||||
cb();
|
||||
} else {
|
||||
gutil.log(gutil.colors.green('Downloading Docker Compose'));
|
||||
request('https://github.com/docker/compose/releases/download/' + packagejson['docker-compose-version'] + '/docker-compose-Darwin-x86_64')
|
||||
.pipe(fs.createWriteStream('./resources/docker-compose')).on('end', cb);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('download-boot2docker-iso', function (cb) {
|
||||
var b2dFile = path.join('resources', 'boot2docker-' + packagejson['docker-version'] + '.iso');
|
||||
if (!fs.existsSync(b2dFile)) {
|
||||
gutil.log(gutil.colors.green('Downloading Boot2Docker iso'));
|
||||
request('https://github.com/boot2docker/boot2docker/releases/download/v' + packagejson['docker-version'] + '/boot2docker.iso')
|
||||
.pipe(fs.createWriteStream(b2dFile)).on('end', cb);
|
||||
} else {
|
||||
cb();
|
||||
}
|
||||
});
|
||||
|
||||
gulp.task('reset', function () {
|
||||
|
|
@ -200,10 +273,10 @@ gulp.task('reset', function () {
|
|||
});
|
||||
|
||||
gulp.task('release', function () {
|
||||
runSequence('download-deps', 'download', 'dist', ['copy', 'images', 'js', 'styles', 'settings'], 'sign', 'zip');
|
||||
runSequence('download-docker', 'download-docker-machine', 'download-docker-compose', 'download-boot2docker-iso', 'download', 'dist', ['copy', 'images', 'js', 'styles', 'settings'], 'sign', 'zip');
|
||||
});
|
||||
|
||||
gulp.task('default', ['download-deps', 'download', 'copy', 'js', 'images', 'styles'], function () {
|
||||
gulp.task('default', ['download-docker', 'download-docker-machine', 'download-docker-compose', 'download-boot2docker-iso', 'download', 'copy', 'js', 'images', 'styles'], function () {
|
||||
gulp.watch('src/**/*.js', ['js']);
|
||||
gulp.watch('index.html', ['copy']);
|
||||
gulp.watch('styles/**/*.less', ['styles']);
|
||||
|
|
|
|||
46
util/deps
46
util/deps
|
|
@ -1,46 +0,0 @@
|
|||
#!/bin/bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
BASE=$DIR/..
|
||||
DOCKER_VERSION=$(node -pe "JSON.parse(process.argv[1])['docker-version']" "$(cat $BASE/package.json)")
|
||||
DOCKER_MACHINE_VERSION=$(node -pe "JSON.parse(process.argv[1])['docker-machine-version']" "$(cat $BASE/package.json)")
|
||||
DOCKER_COMPOSE_VERSION=$(node -pe "JSON.parse(process.argv[1])['docker-compose-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)
|
||||
CURRENT_DOCKER_COMPOSE_VERSION=$($BASE/resources/docker-compose --version | cut -d ',' -f1 | awk '{print $2}' | cut -d '-' -f1)
|
||||
BOOT2DOCKER_FILE=boot2docker-$DOCKER_VERSION.iso
|
||||
|
||||
pushd $BASE/resources > /dev/null
|
||||
|
||||
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
|
||||
chmod +x docker
|
||||
fi
|
||||
|
||||
if [ "$DOCKER_MACHINE_VERSION" != "$CURRENT_DOCKER_MACHINE_VERSION" ]; then
|
||||
echo "-----> Downloading Docker Machine CLI..."
|
||||
rm -rf docker-machine
|
||||
rm -rf docker-machine-*
|
||||
curl -L -o docker-machine https://github.com/docker/machine/releases/download/v$DOCKER_MACHINE_VERSION/docker-machine_darwin-amd64
|
||||
chmod +x docker-machine
|
||||
fi
|
||||
|
||||
if [ "$DOCKER_COMPOSE_VERSION" != "$CURRENT_DOCKER_COMPOSE_VERSION" ]; then
|
||||
echo "-----> Downloading Docker Compose CLI..."
|
||||
rm -rf docker-compose
|
||||
curl -L -o docker-compose https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-Darwin-x86_64
|
||||
chmod +x docker-compose
|
||||
fi
|
||||
|
||||
if [ ! -f $BOOT2DOCKER_FILE ]; then
|
||||
echo "-----> Downloading Boot2Docker iso..."
|
||||
rm -rf boot2docker-*
|
||||
curl -L -o $BOOT2DOCKER_FILE https://github.com/boot2docker/boot2docker/releases/download/v$DOCKER_VERSION/boot2docker.iso
|
||||
fi
|
||||
|
||||
|
||||
popd > /dev/null
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
$scriptpath = $MyInvocation.MyCommand.Path
|
||||
$dir = Split-Path $scriptpath
|
||||
$BasePath = $dir + '\..\'
|
||||
$packageJson = get-content ($BasePath + 'package.json')
|
||||
[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") > $null
|
||||
$serializer = New-Object System.Web.Script.Serialization.JavaScriptSerializer
|
||||
$packageJsonContent = $serializer.DeserializeObject($packageJson)
|
||||
$webclient = New-Object System.Net.WebClient
|
||||
|
||||
$DOCKER_MACHINE_CLI_VERSION = $packageJsonContent['docker-machine-version']
|
||||
$DOCKER_CLI_VERSION = $packageJsonContent['docker-version']
|
||||
|
||||
|
||||
if(-Not (test-path ($BasePath + '\resources\docker'))) {
|
||||
echo "-----> Downloading Docker CLI..."
|
||||
$source = "https://master.dockerproject.com/windows/amd64/docker.exe"
|
||||
$destination = $BasePath + "\resources\docker"
|
||||
$webclient.DownloadFile($source, $destination)
|
||||
}
|
||||
|
||||
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