now fully working

This commit is contained in:
Philipp Kunz 2016-07-20 00:40:37 +02:00
parent 0157ca94e4
commit 687417c03d
8 changed files with 64 additions and 32 deletions

2
dist/cli.js vendored Normal file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
var index = require("./index.js");

8
dist/index.js vendored
View File

@ -4,7 +4,11 @@ const promisechain = require("./npmdocker.promisechain");
promisechain.run()
.then((configArg) => {
if (configArg.exitCode == 0) {
plugins.beautylog.success("Allright test in docker ran through");
plugins.beautylog.success("container ended all right!");
}
else {
plugins.beautylog.error("container ended with error!");
process.exit(1);
}
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0scUJBQXFCLENBQUMsQ0FBQTtBQUMvQyxNQUFZLFlBQVksV0FBTSwwQkFBMEIsQ0FBQyxDQUFBO0FBSXpELFlBQVksQ0FBQyxHQUFHLEVBQUU7S0FDYixJQUFJLENBQUMsQ0FBQyxTQUE4QjtJQUNqQyxFQUFFLENBQUEsQ0FBQyxTQUFTLENBQUMsUUFBUSxJQUFJLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDeEIsT0FBTyxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMscUNBQXFDLENBQUMsQ0FBQztJQUNyRSxDQUFDO0FBQ0wsQ0FBQyxDQUFDLENBQUMifQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0scUJBQXFCLENBQUMsQ0FBQTtBQUMvQyxNQUFZLFlBQVksV0FBTSwwQkFBMEIsQ0FBQyxDQUFBO0FBSXpELFlBQVksQ0FBQyxHQUFHLEVBQUU7S0FDYixJQUFJLENBQUMsQ0FBQyxTQUE4QjtJQUNqQyxFQUFFLENBQUEsQ0FBQyxTQUFTLENBQUMsUUFBUSxJQUFJLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDeEIsT0FBTyxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsNEJBQTRCLENBQUMsQ0FBQztJQUM1RCxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyw2QkFBNkIsQ0FBQyxDQUFDO1FBQ3ZELE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDcEIsQ0FBQztBQUNMLENBQUMsQ0FBQyxDQUFDIn0=

View File

@ -2,17 +2,18 @@
const plugins = require("./npmdocker.plugins");
const paths = require("./npmdocker.paths");
const snippets = require("./npmdocker.snippets");
const npmdocker_promisechain_1 = require("./npmdocker.promisechain");
let config;
let dockerData = {
imageTag: "npmdocker-temp-image:latest",
containerName: "npmdocker-temp-container",
exitCode: 0
containerName: "npmdocker-temp-container"
};
/**
* check if docker is available
*/
let checkDocker = () => {
let done = plugins.q.defer();
npmdocker_promisechain_1.npmdockerOra.text("checking docker...");
if (plugins.shelljs.which("docker")) {
plugins.beautylog.ok("Docker found!");
done.resolve();
@ -27,6 +28,7 @@ let checkDocker = () => {
*/
let buildDockerFile = () => {
let done = plugins.q.defer();
npmdocker_promisechain_1.npmdockerOra.text("building Dockerfile...");
let dockerfile = snippets.dockerfileSnippet({
baseImage: config.baseImage,
command: config.command
@ -43,16 +45,18 @@ let buildDockerFile = () => {
*/
let buildDockerImage = () => {
let done = plugins.q.defer();
plugins.beautylog.log("pulling latest image...");
npmdocker_promisechain_1.npmdockerOra.text("pulling latest base image from registry...");
plugins.shelljs.exec(`docker pull ${config.baseImage}`, {
silent: true
}); // first pull latest version of baseImage
plugins.shelljs.exec(`docker build -f ${paths.dockerfile} -t ${dockerData.imageTag} ${paths.assets}`, {
silent: true
}, () => {
plugins.beautylog.ok("Dockerimage built!");
done.resolve();
});
npmdocker_promisechain_1.npmdockerOra.text("building Dockerimage...");
plugins.shelljs.exec(`docker build -f ${paths.dockerfile} -t ${dockerData.imageTag} ${paths.assets}`, {
silent: true
}, () => {
plugins.beautylog.ok("Dockerimage built!");
done.resolve();
});
}); // first pull latest version of baseImage
return done.promise;
};
/**
@ -60,8 +64,9 @@ let buildDockerImage = () => {
*/
let runDockerImage = () => {
let done = plugins.q.defer();
plugins.beautylog.info("Now starting Container!");
dockerData.exitCode = plugins.shelljs.exec(`docker run -v ${paths.cwd}:/workspace --name ${dockerData.containerName} ${dockerData.imageTag}`).code;
npmdocker_promisechain_1.npmdockerOra.text("starting Container...");
npmdocker_promisechain_1.npmdockerOra.end();
config.exitCode = plugins.shelljs.exec(`docker run -v ${paths.cwd}:/workspace --name ${dockerData.containerName} ${dockerData.imageTag}`).code;
done.resolve();
return done.promise;
};
@ -94,8 +99,8 @@ exports.run = (configArg) => {
.then(deleteDockerContainter)
.then(deleteDockerImage)
.then(() => {
done.resolve(configArg);
done.resolve(config);
});
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmRvY2tlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5kb2NrZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFDL0MsTUFBWSxLQUFLLFdBQU0sbUJBQW1CLENBQUMsQ0FBQTtBQUMzQyxNQUFZLFFBQVEsV0FBTSxzQkFBc0IsQ0FBQyxDQUFBO0FBRWpELElBQUksTUFBTSxDQUFDO0FBQ1gsSUFBSSxVQUFVLEdBQUc7SUF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QUFJLENBQUMsZ0JBQWdCLENBQUM7U0FDdEIsSUFBSSxDQUFDLGNBQWMsQ0FBQztTQUNwQixJQUFJLENBQUMsc0JBQXNCLENBQUM7U0FDNUIsSUFBSSxDQUFDLGlCQUFpQixDQUFDO1NBQ3ZCLElBQUksQ0FBQztRQUNGLElBQUksQ0FBQyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7SUFDekIsQ0FBQyxDQUFDLENBQUE7SUFDTixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUEifQ==

View File

@ -1,3 +1,5 @@
/// <reference types="q" />
import * as plugins from "./npmdocker.plugins";
import { Ora } from "beautylog";
export declare let npmdockerOra: Ora;
export declare let run: () => plugins.q.Promise<{}>;

View File

@ -1,13 +1,18 @@
"use strict";
const plugins = require("./npmdocker.plugins");
const beautylog_1 = require("beautylog");
//modules
const ConfigModule = require("./npmdocker.config");
const DockerModule = require("./npmdocker.docker");
exports.npmdockerOra = new beautylog_1.Ora("npmdocker", "blue");
exports.npmdockerOra.start();
exports.run = () => {
let done = plugins.q.defer();
ConfigModule.run()
.then(DockerModule.run)
.then(done.resolve);
.then((configArg) => {
done.resolve(configArg);
});
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnByb21pc2VjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5wcm9taXNlY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFHL0MsU0FBUztBQUNULE1BQVksWUFBWSxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFDbkQsTUFBWSxZQUFZLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUV4QyxXQUFHLEdBQUc7SUFDYixJQUFJLElBQUks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zVCLENBQUMsQ0FBQyxDQUFBO0lBQ04sTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFBIn0=

View File

@ -6,7 +6,10 @@ import * as ConfigModule from "./npmdocker.config";
promisechain.run()
.then((configArg:ConfigModule.IConfig) => {
if(configArg.exitCode == 0){
plugins.beautylog.success("Allright test in docker ran through");
plugins.beautylog.success("container ended all right!");
} else {
plugins.beautylog.error("container ended with error!");
process.exit(1);
}
});

View File

@ -2,17 +2,20 @@ import * as plugins from "./npmdocker.plugins";
import * as paths from "./npmdocker.paths";
import * as snippets from "./npmdocker.snippets";
import {npmdockerOra} from "./npmdocker.promisechain";
let config;
let dockerData = {
imageTag: "npmdocker-temp-image:latest",
containerName: "npmdocker-temp-container",
exitCode:0
containerName: "npmdocker-temp-container"
};
/**
* check if docker is available
*/
let checkDocker = () => {
let done = plugins.q.defer();
npmdockerOra.text("checking docker...");
if(plugins.shelljs.which("docker")){
plugins.beautylog.ok("Docker found!")
done.resolve();
@ -27,6 +30,7 @@ let checkDocker = () => {
*/
let buildDockerFile = () => {
let done = plugins.q.defer();
npmdockerOra.text("building Dockerfile...");
let dockerfile:string = snippets.dockerfileSnippet({
baseImage:config.baseImage,
command:config.command
@ -44,16 +48,18 @@ let buildDockerFile = () => {
*/
let buildDockerImage = () => {
let done = plugins.q.defer();
plugins.beautylog.log("pulling latest image...");
npmdockerOra.text("pulling latest base image from registry...");
plugins.shelljs.exec(`docker pull ${config.baseImage}`,{
silent:true
}); // first pull latest version of baseImage
plugins.shelljs.exec(`docker build -f ${paths.dockerfile} -t ${dockerData.imageTag} ${paths.assets}`,{
silent:true
},() => {
plugins.beautylog.ok("Dockerimage built!")
done.resolve();
});
npmdockerOra.text("building Dockerimage...");
plugins.shelljs.exec(`docker build -f ${paths.dockerfile} -t ${dockerData.imageTag} ${paths.assets}`,{
silent:true
},() => {
plugins.beautylog.ok("Dockerimage built!")
done.resolve();
});
}); // first pull latest version of baseImage
return done.promise
};
@ -62,8 +68,9 @@ let buildDockerImage = () => {
*/
let runDockerImage = () => {
let done = plugins.q.defer();
plugins.beautylog.info("Now starting Container!");
dockerData.exitCode = plugins.shelljs.exec(`docker run -v ${paths.cwd}:/workspace --name ${dockerData.containerName} ${dockerData.imageTag}`).code;
npmdockerOra.text("starting Container...");
npmdockerOra.end();
config.exitCode = plugins.shelljs.exec(`docker run -v ${paths.cwd}:/workspace --name ${dockerData.containerName} ${dockerData.imageTag}`).code;
done.resolve();
return done.promise;
};
@ -101,7 +108,7 @@ export let run = (configArg) => {
.then(deleteDockerContainter)
.then(deleteDockerImage)
.then(() => {
done.resolve(configArg);
done.resolve(config);
})
return done.promise;
}

View File

@ -1,14 +1,18 @@
import * as plugins from "./npmdocker.plugins";
import * as paths from "./npmdocker.paths";
import {Ora} from "beautylog";
//modules
import * as ConfigModule from "./npmdocker.config";
import * as DockerModule from "./npmdocker.docker";
export let npmdockerOra = new Ora("npmdocker","blue");
npmdockerOra.start();
export let run = () => {
let done = plugins.q.defer();
ConfigModule.run()
.then(DockerModule.run)
.then(done.resolve)
.then((configArg) => {
done.resolve(configArg);
})
return done.promise;
}