diff --git a/dist/npmci.build.docker.d.ts b/dist/npmci.build.docker.d.ts index 592441a..9d82074 100644 --- a/dist/npmci.build.docker.d.ts +++ b/dist/npmci.build.docker.d.ts @@ -1,9 +1,10 @@ export declare let build: () => any; export declare class Dockerfile { filePath: string; - buildTag: string; repo: string; version: string; + cleanTag: string; + buildTag: string; content: string; baseImage: string; constructor(options: { diff --git a/dist/npmci.build.docker.js b/dist/npmci.build.docker.js index 26ae75e..c888adc 100644 --- a/dist/npmci.build.docker.js +++ b/dist/npmci.build.docker.js @@ -6,7 +6,11 @@ exports.build = function () { ; plugins.gulp.dest("./Dockerfile*") .pipe(readDockerfiles) - .pipe(plugins.gulpFunction(done.resolve, "atEnd")); + .pipe(plugins.gulpFunction(function () { + sortDockerfiles() + .then(buildDockerfiles) + .then(done.resolve); + }, "atEnd")); return done.promise; }; var readDockerfiles = function () { @@ -16,21 +20,56 @@ var readDockerfiles = function () { read: true }); NpmciEnv.dockerFiles.push(myDockerfile); - file["Dockerfile"] = myDockerfile; cb(null, file); }; }; -var buildDockerfiles = function () { - return function (file, enc, cb) { - file.myDockerfile.build(); - cb(); +var sortDockerfiles = function () { + var done = plugins.q.defer(); + var redoSort; + var sortFunction = function () { + redoSort = false; + var notYetBuiltImages = []; + NpmciEnv.dockerFiles.forEach(function (dockerFileArg) { + notYetBuiltImages.push(dockerFileArg.cleanTag); + }); + NpmciEnv.dockerFiles.sort(function (a, b) { + plugins.beautylog.log("sort build order for Dockerimages"); + var aIndex = notYetBuiltImages.indexOf(a.cleanTag); + if (aIndex != -1) { + notYetBuiltImages.splice(aIndex, 1); + } + if (notYetBuiltImages.indexOf(b.cleanTag) != -1) { + redoSort = true; + return -1; + } + else { + return 0; + } + }); + if (redoSort) { + sortFunction(); + } + else { + done.resolve(); + } }; + sortFunction(); + return done.promise; +}; +var buildDockerfiles = function () { + var done = plugins.q.defer(); + NpmciEnv.dockerFiles.forEach(function (dockerfileArg) { + dockerfileArg.build(); + }); + done.resolve(); + return done.promise; }; var Dockerfile = (function () { function Dockerfile(options) { this.filePath = options.filePath; this.repo = NpmciEnv.repo.user + "/" + NpmciEnv.repo.repo; this.version = dockerFileVersion(plugins.path.parse(options.filePath).base); + this.cleanTag = this.repo + ":" + this.version; if (options.filePath && options.read) { this.content = plugins.smartfile.local.toStringSync(plugins.path.resolve(options.filePath)); } @@ -93,4 +132,4 @@ exports.dockerTag = function (repoArg, versionArg) { return tagString; }; -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLmJ1aWxkLmRvY2tlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsSUFBWSxPQUFPLFdBQU0saUJBQ3pCLENBQUMsQ0FEeUM7QUFDMUMsSUFBWSxRQUFRLFdBQU0sYUFBYSxDQUFDLENBQUE7QUFHN0IsYUFBSyxHQUFHO0lBQ2YsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQztJQUFBLENBQUM7SUFDOUIsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsZUFBZSxDQUFDO1NBQzdCLElBQUksQ0FBQyxlQUFlLENBQUM7U0FDckIsSUFBSSxDQUFDLE9BQU8sQ0FBQyxZQUFZLENBQUMsSUFBSSxDQUFDLE9BQU8sRUFBQyxPQUFPLENBQUMsQ0FBQyxDQUFDO0lBQ3RELE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQTtBQUVELElBQUksZUFBZSxHQUFHO0lBQ2xCLE1BQU0sQ0FBQyxVQUFTLElBQUksRUFBQyxHQUFHLEVBQUMsRUFBRTtRQUN2QixJQUFJLFlBQVksR0FBRyxJQUFJLFVBQVUsQ0FBQztZQUM5QixRQUFRLEVBQUMsSUFBSSxDQUFDLElBQUk7WUFDbEIsSUFBSSxFQUFDLElBQUk7U0FDWixDQUFD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hblRhZyk7XG4gICAgICAgICAgICBpZihhSW5kZXggIT0gLTEpe25vdFlldEJ1aWx0SW1hZ2VzLnNwbGljZShhSW5kZXgsMSl9XG4gICAgICAgICAgICBpZihub3RZZXRCdWlsdEltYWdlcy5pbmRleE9mKGIuY2xlYW5UYWcpICE9IC0xKXtcbiAgICAgICAgICAgICAgICByZWRvU29ydCA9IHRydWU7XG4gICAgICAgICAgICAgICAgcmV0dXJuIC0xO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gMFxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgaWYocmVkb1NvcnQpe1xuICAgICAgICAgICAgc29ydEZ1bmN0aW9uKCk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBkb25lLnJlc29sdmUoKTtcbiAgICAgICAgfVxuICAgIH07XG4gICAgc29ydEZ1bmN0aW9uKCk7XG4gICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcbn1cblxubGV0IGJ1aWxkRG9ja2VyZmlsZXMgPSBmdW5jdGlvbigpe1xuICAgIGxldCBkb25lID0gcGx1Z2lucy5xLmRlZmVyKCk7XG4gICAgTnBtY2lFbnYuZG9ja2VyRmlsZXMuZm9yRWFjaChmdW5jdGlvbihkb2NrZXJmaWxlQXJnKXtcbiAgICAgICAgZG9ja2VyZmlsZUFyZy5idWlsZCgpO1xuICAgIH0pXG4gICAgZG9uZS5yZXNvbHZlKCk7XG4gICAgcmV0dXJuIGRvbmUucHJvbWlzZTtcbn1cblxuZXhwb3J0IGNsYXNzIERvY2tlcmZpbGUge1xuICAgIGZpbGVQYXRoOnN0cmluZztcbiAgICByZXBvOnN0cmluZztcbiAgICB2ZXJzaW9uOnN0cmluZztcbiAgICBjbGVhblRhZzpzdHJpbmc7XG4gICAgYnVpbGRUYWc6c3RyaW5nO1xuICAgIGNvbnRlbnQ6c3RyaW5nO1xuICAgIGJhc2VJbWFnZTpzdHJpbmc7XG4gIC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oZG9ja2VyZmlsZUNvbnRlbnRBcmc6c3RyaW5nKXtcbiAgICBsZXQgYmFzZUltYWdlUmVnZXggPSAvRlJPTVxccyhbYS16QS16MC05XFwvXFwtXFw6XSopXFxuL1xuICAgIGxldCByZWdleFJlc3VsdEFycmF5ID0gYmFzZUltYWdlUmVnZXguZXhlYyhkb2NrZXJmaWxlQ29udGVudEFyZylcbiAgICByZXR1cm4gcmVnZXhSZXN1bHRBcnJheVsxXTtcbn1cblxuZXhwb3J0IGxldCBkb2NrZXJUYWcgPSBmdW5jdGlvbihyZXBvQXJnOnN0cmluZyx2ZXJzaW9uQXJnOnN0cmluZyk6c3RyaW5ne1xuICAgIGxldCB0YWdTdHJpbmc6c3RyaW5nO1xuICAgIGxldCByZWdpc3RyeSA9IE5wbWNpRW52LmRvY2tlclJlZ2lzdHJ5O1xuICAgIGlmKHByb2Nlc3MuZW52LkNJX0JVSUxEX1NUQUdFID09IFwidGVzdFwiKXtcbiAgICAgICAgcmVnaXN0cnkgPSBcInJlZ2lzdHJ5LmdpdGxhYi5jb21cIjtcbiAgICB9IFxuICAgIGxldCByZXBvID0gcmVwb0FyZztcbiAgICBsZXQgdmVyc2lvbiA9IHZlcnNpb25Bcmc7XG4gICAgaWYocHJvY2Vzcy5lbnYuQ0lfQlVJTERfU1RBR0UgPT0gXCJ0ZXN0XCIgfHwgcHJvY2Vzcy5lbnYuQ0lfQlVJTERfU1RBR0UgPT0gXCJidWlsZFwiKXtcbiAgICAgICAgdmVyc2lvbiA9IHZlcnNpb24gKyBcIl90ZXN0XCI7XG4gICAgfVxuICAgIHRhZ1N0cmluZyA9IHJlZ2lzdHJ5ICsgXCIvXCIgKyByZXBvICsgXCI6XCIgKyB2ZXJzaW9uO1xuICAgIHJldHVybiB0YWdTdHJpbmc7XG59O1xuIl19 diff --git a/ts/npmci.build.docker.ts b/ts/npmci.build.docker.ts index 672ef23..d9c5cd9 100644 --- a/ts/npmci.build.docker.ts +++ b/ts/npmci.build.docker.ts @@ -6,7 +6,11 @@ export let build = function(){ let done = plugins.q.defer();; plugins.gulp.dest("./Dockerfile*") .pipe(readDockerfiles) - .pipe(plugins.gulpFunction(done.resolve,"atEnd")); + .pipe(plugins.gulpFunction(function(){ + sortDockerfiles() + .then(buildDockerfiles) + .then(done.resolve); + },"atEnd")); return done.promise; } @@ -19,29 +23,62 @@ let readDockerfiles = function(){ NpmciEnv.dockerFiles.push( myDockerfile ); - file["Dockerfile"] = myDockerfile; cb(null,file); }; } +let sortDockerfiles = function(){ + let done = plugins.q.defer(); + let redoSort:boolean; + let sortFunction = function(){ + redoSort = false; + let notYetBuiltImages:string[] = []; + NpmciEnv.dockerFiles.forEach((dockerFileArg)=>{ + notYetBuiltImages.push(dockerFileArg.cleanTag); + }); + NpmciEnv.dockerFiles.sort(function(a,b){ + plugins.beautylog.log("sort build order for Dockerimages"); + let aIndex = notYetBuiltImages.indexOf(a.cleanTag); + if(aIndex != -1){notYetBuiltImages.splice(aIndex,1)} + if(notYetBuiltImages.indexOf(b.cleanTag) != -1){ + redoSort = true; + return -1; + } else { + return 0 + } + }); + if(redoSort){ + sortFunction(); + } else { + done.resolve(); + } + }; + sortFunction(); + return done.promise; +} + let buildDockerfiles = function(){ - return function(file,enc,cb){ - file.myDockerfile.build(); - cb(); - } + let done = plugins.q.defer(); + NpmciEnv.dockerFiles.forEach(function(dockerfileArg){ + dockerfileArg.build(); + }) + done.resolve(); + return done.promise; } export class Dockerfile { filePath:string; - buildTag:string; repo:string; version:string; + cleanTag:string; + buildTag:string; content:string; baseImage:string; constructor(options:{filePath?:string,fileContents?:string|Buffer,read?:boolean}){ this.filePath = options.filePath; this.repo = NpmciEnv.repo.user + "/" + NpmciEnv.repo.repo; this.version = dockerFileVersion(plugins.path.parse(options.filePath).base); + this.cleanTag = this.repo + ":" + this.version; if(options.filePath && options.read){ this.content = plugins.smartfile.local.toStringSync(plugins.path.resolve(options.filePath)); };