even more docker
This commit is contained in:
parent
a38996b98c
commit
51334c297d
@ -26,11 +26,14 @@ let makeDockerfiles = function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class Dockerfile {
|
export class Dockerfile {
|
||||||
|
filePath:string;
|
||||||
|
buildTag:string;
|
||||||
repo:string;
|
repo:string;
|
||||||
version:string;
|
version:string;
|
||||||
content:string;
|
content:string;
|
||||||
baseImage:string;
|
baseImage:string;
|
||||||
constructor(options:{filePath?:string,fileContents?:string|Buffer,read?:boolean}){
|
constructor(options:{filePath?:string,fileContents?:string|Buffer,read?:boolean}){
|
||||||
|
this.filePath = options.filePath;
|
||||||
this.repo = NpmciEnv.repo.user + "/" + NpmciEnv.repo.repo;
|
this.repo = NpmciEnv.repo.user + "/" + NpmciEnv.repo.repo;
|
||||||
this.version = dockerFileVersion(plugins.path.parse(options.filePath).base);
|
this.version = dockerFileVersion(plugins.path.parse(options.filePath).base);
|
||||||
if(options.filePath && options.read){
|
if(options.filePath && options.read){
|
||||||
@ -39,10 +42,16 @@ export class Dockerfile {
|
|||||||
this.baseImage = dockerBaseImage(this.content);
|
this.baseImage = dockerBaseImage(this.content);
|
||||||
};
|
};
|
||||||
build(){
|
build(){
|
||||||
|
let tag = dockerTag(this.repo,this.version);
|
||||||
|
plugins.shelljs.exec("docker build -t " + tag + " -f " + this.filePath + " .");
|
||||||
|
this.buildTag = tag;
|
||||||
};
|
};
|
||||||
push(){
|
push(){
|
||||||
|
if(this.buildTag){
|
||||||
|
plugins.shelljs.exec("docker push " + this.buildTag);
|
||||||
|
} else {
|
||||||
|
plugins.beautylog.error("Dockerfile hasn't been built yet!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,10 +73,17 @@ let dockerBaseImage = function(dockerfileContentArg:string){
|
|||||||
return regexResultArray[1];
|
return regexResultArray[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
export let dockerTagVersion = function(){
|
export let dockerTag = function(repoArg:string,versionArg:string):string{
|
||||||
|
let tagString:string;
|
||||||
|
let registry = NpmciEnv.dockerRegistry;
|
||||||
if(process.env.CI_BUILD_STAGE == "test"){
|
if(process.env.CI_BUILD_STAGE == "test"){
|
||||||
return "test";
|
registry = "registry.gitlab.com";
|
||||||
} else {
|
}
|
||||||
return "latest"
|
let repo = repoArg;
|
||||||
|
let version = versionArg;
|
||||||
|
if(process.env.CI_BUILD_STAGE == "test" || process.env.CI_BUILD_STAGE == "build"){
|
||||||
|
version = version + "_test";
|
||||||
}
|
}
|
||||||
|
tagString = registry + "/" + repo + ":" + version;
|
||||||
|
return tagString;
|
||||||
};
|
};
|
||||||
|
0
ts/npmci.get.ts
Normal file
0
ts/npmci.get.ts
Normal file
@ -51,9 +51,10 @@ export let prepare = function(serviceArg:string){
|
|||||||
case "npm":
|
case "npm":
|
||||||
return npm();
|
return npm();
|
||||||
case "docker":
|
case "docker":
|
||||||
return docker();
|
return docker()
|
||||||
|
.then(dockerGitlab); // always also login to gitlab registry for tests
|
||||||
case "docker-gitlab":
|
case "docker-gitlab":
|
||||||
return dockerGitlab();
|
return dockerGitlab()
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user