now sorting dockerfiles before build
This commit is contained in:
parent
839dac1fe8
commit
1c7542c970
3
dist/npmci.build.docker.d.ts
vendored
3
dist/npmci.build.docker.d.ts
vendored
@ -1,9 +1,10 @@
|
|||||||
export declare let build: () => any;
|
export declare let build: () => any;
|
||||||
export declare class Dockerfile {
|
export declare class Dockerfile {
|
||||||
filePath: string;
|
filePath: string;
|
||||||
buildTag: string;
|
|
||||||
repo: string;
|
repo: string;
|
||||||
version: string;
|
version: string;
|
||||||
|
cleanTag: string;
|
||||||
|
buildTag: string;
|
||||||
content: string;
|
content: string;
|
||||||
baseImage: string;
|
baseImage: string;
|
||||||
constructor(options: {
|
constructor(options: {
|
||||||
|
53
dist/npmci.build.docker.js
vendored
53
dist/npmci.build.docker.js
vendored
File diff suppressed because one or more lines are too long
@ -6,7 +6,11 @@ export let build = function(){
|
|||||||
let done = plugins.q.defer();;
|
let done = plugins.q.defer();;
|
||||||
plugins.gulp.dest("./Dockerfile*")
|
plugins.gulp.dest("./Dockerfile*")
|
||||||
.pipe(readDockerfiles)
|
.pipe(readDockerfiles)
|
||||||
.pipe(plugins.gulpFunction(done.resolve,"atEnd"));
|
.pipe(plugins.gulpFunction(function(){
|
||||||
|
sortDockerfiles()
|
||||||
|
.then(buildDockerfiles)
|
||||||
|
.then(done.resolve);
|
||||||
|
},"atEnd"));
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,29 +23,62 @@ let readDockerfiles = function(){
|
|||||||
NpmciEnv.dockerFiles.push(
|
NpmciEnv.dockerFiles.push(
|
||||||
myDockerfile
|
myDockerfile
|
||||||
);
|
);
|
||||||
file["Dockerfile"] = myDockerfile;
|
|
||||||
cb(null,file);
|
cb(null,file);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let buildDockerfiles = function(){
|
let sortDockerfiles = function(){
|
||||||
return function(file,enc,cb){
|
let done = plugins.q.defer();
|
||||||
file.myDockerfile.build();
|
let redoSort:boolean;
|
||||||
cb();
|
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(){
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
NpmciEnv.dockerFiles.forEach(function(dockerfileArg){
|
||||||
|
dockerfileArg.build();
|
||||||
|
})
|
||||||
|
done.resolve();
|
||||||
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Dockerfile {
|
export class Dockerfile {
|
||||||
filePath:string;
|
filePath:string;
|
||||||
buildTag:string;
|
|
||||||
repo:string;
|
repo:string;
|
||||||
version:string;
|
version:string;
|
||||||
|
cleanTag:string;
|
||||||
|
buildTag:string;
|
||||||
content:string;
|
content:string;
|
||||||
baseImage:string;
|
baseImage:string;
|
||||||
constructor(options:{filePath?:string,fileContents?:string|Buffer,read?:boolean}){
|
constructor(options:{filePath?:string,fileContents?:string|Buffer,read?:boolean}){
|
||||||
this.filePath = options.filePath;
|
this.filePath = options.filePath;
|
||||||
this.repo = NpmciEnv.repo.user + "/" + NpmciEnv.repo.repo;
|
this.repo = NpmciEnv.repo.user + "/" + NpmciEnv.repo.repo;
|
||||||
this.version = dockerFileVersion(plugins.path.parse(options.filePath).base);
|
this.version = dockerFileVersion(plugins.path.parse(options.filePath).base);
|
||||||
|
this.cleanTag = this.repo + ":" + this.version;
|
||||||
if(options.filePath && options.read){
|
if(options.filePath && options.read){
|
||||||
this.content = plugins.smartfile.local.toStringSync(plugins.path.resolve(options.filePath));
|
this.content = plugins.smartfile.local.toStringSync(plugins.path.resolve(options.filePath));
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user