more docker

This commit is contained in:
Philipp Kunz 2016-06-05 04:19:54 +02:00
parent ab62b979bd
commit a38996b98c
2 changed files with 28 additions and 18 deletions

View File

@ -21,17 +21,22 @@ let makeDockerfiles = function(){
read:true
})
);
cb();
};
}
export class Dockerfile {
repo:string;
version:string;
content:string;
baseImage:string;
constructor(options:{filePath?:string,fileContents?:string|Buffer,read?:boolean}){
this.repo = NpmciEnv.repo.user + "/" + NpmciEnv.repo.repo;
this.version = dockerFileVersion(plugins.path.parse(options.filePath).base);
if(options.filePath && options.read){
}
this.content = plugins.smartfile.local.toStringSync(plugins.path.resolve(options.filePath));
};
this.baseImage = dockerBaseImage(this.content);
};
build(){
@ -39,7 +44,24 @@ export class Dockerfile {
push(){
}
}
let dockerFileVersion = function(dockerfileNameArg:string):string{
let versionString:string;
let versionRegex = /Dockerfile_([a-zA-Z0-9\.]*)$/;
let regexResultArray = versionRegex.exec(dockerfileNameArg);
if(regexResultArray.length = 2){
versionString = regexResultArray[1];
} else {
versionString = "latest";
}
return versionString;
}
let dockerBaseImage = function(dockerfileContentArg:string){
let baseImageRegex = /FROM\s([a-zA-z0-9\/\-\:]*)\n/
let regexResultArray = baseImageRegex.exec(dockerfileContentArg)
return regexResultArray[1];
}
export let dockerTagVersion = function(){
@ -48,16 +70,4 @@ export let dockerTagVersion = function(){
} else {
return "latest"
}
}
export let tagDocker = function(){
return NpmciEnv.dockerRegistry + "/" + NpmciEnv.repo.user + "/" + NpmciEnv.repo.repo + ":" + dockerTagVersion() +" .";
}
export let dockerTagTest = function(){
return NpmciEnv.dockerRegistry + "/" + NpmciEnv.repo.user + "/" + NpmciEnv.repo.repo + ":test .";
}
export let dockerTagRelease = function(){
return NpmciEnv.dockerRegistry + "/" + NpmciEnv.repo.user + "/" + NpmciEnv.repo.repo + ":latest .";
}
};

View File

@ -2,10 +2,10 @@ import "typings-global";
export import beautylog = require("beautylog");
export let commander = require("commander");
export let gulp = require("gulp");
export let path = require("path");
export import path = require("path");
export let q = require("q");
export let request = require("request");
export let shelljs = require("shelljs");
export let smartssh = require("smartssh");
export import smartssh = require("smartssh");
export import smartstring = require("smartstring");
export import smartfile = require("smartfile");