now building and pushing Dockerfiles with automatic tag recognition
This commit is contained in:
@ -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){
|
||||
|
@ -8,6 +8,6 @@ export let dockerTestTag:string;
|
||||
export let dockerReleaseTag:string;
|
||||
|
||||
export let dockerRegistry; // will be set by npmci.prepare
|
||||
export let dockerImages;
|
||||
export let dockerFiles:Dockerfile[];
|
||||
export let dockerFilesBuilt:Dockerfile[] = [];
|
||||
export let dockerFiles:Dockerfile[] = [];
|
||||
|
||||
|
@ -2,6 +2,7 @@ import "typings-global";
|
||||
export import beautylog = require("beautylog");
|
||||
export let commander = require("commander");
|
||||
export let gulp = require("gulp");
|
||||
export let gulpFunction = require("gulp-function");
|
||||
export import path = require("path");
|
||||
export let q = require("q");
|
||||
export let request = require("request");
|
||||
|
@ -2,7 +2,7 @@ import "typings-global";
|
||||
import * as plugins from "./npmci.plugins";
|
||||
import {prepare} from "./npmci.prepare";
|
||||
import {bash} from "./npmci.bash";
|
||||
import * as env from "./npmci.env";
|
||||
import * as NpmciEnv from "./npmci.env";
|
||||
|
||||
export let publish = (serviceArg:string = "npm") => {
|
||||
switch (serviceArg){
|
||||
@ -26,5 +26,17 @@ let publishNpm = function(){
|
||||
|
||||
let publishDocker = function(){
|
||||
let done = plugins.q.defer();
|
||||
NpmciEnv.dockerFilesBuilt.forEach(function(dockerfileArg){
|
||||
dockerfileArg.push();
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
};
|
||||
|
||||
let publishDockerTest = function(){
|
||||
let done = plugins.q.defer();
|
||||
NpmciEnv.dockerFilesBuilt.forEach(function(dockerfileArg){
|
||||
dockerfileArg.push();
|
||||
});
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
}
|
Reference in New Issue
Block a user