now building and pushing Dockerfiles with automatic tag recognition

This commit is contained in:
2016-06-05 05:16:14 +02:00
parent 6b72652c7a
commit 9c7afba849
11 changed files with 89 additions and 34 deletions

View File

@@ -3,28 +3,34 @@ import * as NpmciEnv from "./npmci.env";
export let build = function(){
let done = plugins.q.defer();
done.resolve();
let done = plugins.q.defer();;
plugins.gulp.dest("./Dockerfile*")
.pipe(readDockerfiles)
.pipe(plugins.gulpFunction(done.resolve,"atEnd"));
return done.promise;
}
let readDockerfiles = function(){
plugins.gulp.dest("./Dockerfile*")
.pipe(makeDockerfiles);
};
let makeDockerfiles = function(){
return function(file,enc,cb){
let myDockerfile = new Dockerfile({
filePath:file.path,
read:true
});
NpmciEnv.dockerFiles.push(
new Dockerfile({
filePath:file.path,
read:true
})
myDockerfile
);
cb();
file["Dockerfile"] = myDockerfile;
cb(null,file);
};
}
let buildDockerfiles = function(){
return function(file,enc,cb){
file.myDockerfile.build();
cb();
}
}
export class Dockerfile {
filePath:string;
buildTag:string;
@@ -42,9 +48,15 @@ export class Dockerfile {
this.baseImage = dockerBaseImage(this.content);
};
build(){
let tag = dockerTag(this.repo,this.version);
plugins.shelljs.exec("docker build -t " + tag + " -f " + this.filePath + " .");
this.buildTag = tag;
if(!this.buildTag){
let tag = dockerTag(this.repo,this.version);
plugins.shelljs.exec("docker build -t " + tag + " -f " + this.filePath + " .");
this.buildTag = tag;
NpmciEnv.dockerFilesBuilt.push(this);
} else {
plugins.beautylog.error("This Dockerfile already has been built!");
}
};
push(){
if(this.buildTag){