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 class Dockerfile {
|
||||
filePath: string;
|
||||
buildTag: string;
|
||||
repo: string;
|
||||
version: string;
|
||||
cleanTag: string;
|
||||
buildTag: string;
|
||||
content: string;
|
||||
baseImage: string;
|
||||
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();;
|
||||
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 buildDockerfiles = function(){
|
||||
return function(file,enc,cb){
|
||||
file.myDockerfile.build();
|
||||
cb();
|
||||
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(){
|
||||
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));
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user