diff --git a/ts/npmci.build.docker.ts b/ts/npmci.build.docker.ts index ebd0b5c..de32a1f 100644 --- a/ts/npmci.build.docker.ts +++ b/ts/npmci.build.docker.ts @@ -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 ."; -} +}; diff --git a/ts/npmci.plugins.ts b/ts/npmci.plugins.ts index 413dbb3..e0542fd 100644 --- a/ts/npmci.plugins.ts +++ b/ts/npmci.plugins.ts @@ -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"); \ No newline at end of file