Compare commits

...

22 Commits

Author SHA1 Message Date
30b88d36ae 1.1.6 2016-07-29 22:19:58 +02:00
2c49978674 now also removes old running containers 2016-07-29 22:19:53 +02:00
4dffa31f7d 1.1.5 2016-07-29 22:00:27 +02:00
6904088af8 now removes any previous containers to avoid name space conflicts after errors 2016-07-29 22:00:22 +02:00
b9618a86a6 1.1.4 2016-07-29 03:17:09 +02:00
f1d232a333 add right images to gitlab ci 2016-07-29 03:16:59 +02:00
aa66a3bb86 1.1.3 2016-07-29 03:16:09 +02:00
fbaeb63e4d fix gitlab ci 2016-07-29 03:16:04 +02:00
d60e6a4aa6 1.1.2 2016-07-29 03:09:51 +02:00
90e3e24803 fix gitlab.yml 2016-07-29 03:09:25 +02:00
2372ad7681 fix gitlab ci 2016-07-29 03:05:01 +02:00
02490ef011 fix gitlab ci 2016-07-29 03:03:07 +02:00
2388da50a1 fix gitlab ci 2016-07-29 00:55:11 +02:00
141358595e fix gitlab ci 2016-07-29 00:54:25 +02:00
fc54362312 1.1.1 2016-07-29 00:52:38 +02:00
f9f0119121 now has better support for docker in docker 2016-07-29 00:52:30 +02:00
46e4ed1c8b 1.1.0 2016-07-28 18:01:07 +02:00
25b3cc1045 added dockerSock option 2016-07-28 18:01:02 +02:00
ce996f43a0 Update .gitlab-ci.yml 2016-07-20 15:44:06 +00:00
4e5af75559 1.0.5 2016-07-20 00:45:39 +02:00
62396c52e9 1.0.4 2016-07-20 00:42:29 +02:00
e86773c151 add environment tag 2016-07-20 00:42:22 +02:00
15 changed files with 151 additions and 46 deletions

1
.gitignore vendored
View File

@ -2,4 +2,5 @@ node_modules/
coverage/
docs/
test/
assets/
.nogit/

View File

@ -1,35 +1,43 @@
image: hosttoday/ht-docker-node:npmts
image: hosttoday/ht-docker-dbase:npmts
services:
- docker:dind
stages:
- test
- release
- trigger
testLEGACY:
test:
stage: test
script:
- npmci test legacy
tags:
- docker
testLTS:
stage: test
script:
- npmci test lts
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
- npm install
- npm test
tags:
- docker
- lossless
- priv
release:
image: hosttoday/ht-docker-node:npmts
stage: release
environment: npmjs-com_registry
script:
- npmci publish
only:
- tags
tags:
- docker
- lossless
- priv
trigger:
image: hosttoday/ht-docker-node:npmts
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
- lossless
- priv

View File

@ -1,5 +1,5 @@
FROM hosttoday/ht-docker-node:npmts
RUN mkdir /workspace
COPY ./buildContextDir /workspace
WORKDIR /workspace
ENV CI=true
CMD ["npm","test"];

View File

@ -3,6 +3,7 @@ import * as plugins from "./npmdocker.plugins";
export interface IConfig {
baseImage: string;
command: string;
dockerSock: boolean;
exitCode?: number;
}
export declare let run: () => plugins.q.Promise<{}>;

View File

@ -4,7 +4,8 @@ let config = plugins.npmextra.dataFor({
toolName: "npmdocker",
defaultSettings: {
baseImage: "hosttoday/ht-docker-node:npmts",
command: "npm test"
command: "npm test",
dockerSock: false
}
});
exports.run = () => {
@ -12,4 +13,4 @@ exports.run = () => {
done.resolve(config);
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFTL0MsSUFBSSxNQUFNLEdBQVcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQUM7SUFDMUMsUUFBUSxFQUFDLFdBQVc7SUFDcEIsZUFBZSxFQUFFO1FBQ2IsU0FBUyxFQUFDLGdDQUFnQztRQUMxQyxPQUFPLEVBQUMsVUFBVTtLQUNyQjtDQUNKLENBQUMsQ0FBQztBQUVRLFdBQUcsR0FBRztJQUNiLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNyQixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUEifQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFVL0MsSUFBSSxNQUFNLEdBQVcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQUM7SUFDMUMsUUFBUSxFQUFDLFdBQVc7SUFDcEIsZUFBZSxFQUFFO1FBQ2IsU0FBUyxFQUFDLGdDQUFnQztRQUMxQyxPQUFPLEVBQUMsVUFBVTtRQUNsQixVQUFVLEVBQUUsS0FBSztLQUNwQjtDQUNKLENBQUMsQ0FBQztBQUVRLFdBQUcsR0FBRztJQUNiLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNyQixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUEifQ==

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
export declare let cwd: string;
export declare let packageBase: string;
export declare let assets: string;
export declare let buildContextDir: string;
export declare let dockerfile: string;

View File

@ -5,5 +5,8 @@ exports.cwd = process.cwd();
exports.packageBase = plugins.path.join(__dirname, "../");
exports.assets = plugins.path.join(exports.packageBase, "assets/");
plugins.smartfile.fs.ensureDirSync(exports.assets);
exports.buildContextDir = plugins.path.join(exports.assets, "buildContextDir");
plugins.smartfile.fs.ensureDirSync(exports.buildContextDir);
// files
exports.dockerfile = plugins.path.join(exports.assets, "Dockerfile");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFBcUIsQ0FBQyxDQUFBO0FBRS9DLGNBQWM7QUFDSCxXQUFHLEdBQUcsT0FBTyxDQUFDLEdBQUcsRUFBRSxDQUFDO0FBQ3BCLG1CQUFXLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLEtBQUssQ0FBQyxDQUFDO0FBQ2pELGNBQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxtQkFBVyxFQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzdELE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGFBQWEsQ0FBQyxjQUFNLENBQUMsQ0FBQztBQUNoQyxrQkFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLGNBQU0sRUFBQyxZQUFZLENBQUMsQ0FBQyJ9
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFBcUIsQ0FBQyxDQUFBO0FBRS9DLGNBQWM7QUFDSCxXQUFHLEdBQUcsT0FBTyxDQUFDLEdBQUcsRUFBRSxDQUFDO0FBQ3BCLG1CQUFXLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLEtBQUssQ0FBQyxDQUFDO0FBQ2xELGNBQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxtQkFBVyxFQUFFLFNBQVMsQ0FBQyxDQUFDO0FBQzlELE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGFBQWEsQ0FBQyxjQUFNLENBQUMsQ0FBQztBQUVoQyx1QkFBZSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLGNBQU0sRUFBQyxpQkFBaUIsQ0FBQyxDQUFDO0FBQ3pFLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGFBQWEsQ0FBQyx1QkFBZSxDQUFDLENBQUM7QUFFcEQsUUFBUTtBQUNHLGtCQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsY0FBTSxFQUFFLFlBQVksQ0FBQyxDQUFDIn0=

View File

@ -12,7 +12,7 @@ exports.dockerfileSnippet = (optionsArg) => {
;
return plugins.smartstring.indent.normalize(`
FROM ${optionsArg.baseImage}
RUN mkdir /workspace
COPY ./buildContextDir /workspace
WORKDIR /workspace
ENV CI=true
CMD [${commandString}];

View File

@ -1,6 +1,7 @@
{
"npmts":{
"mode":"default",
"cli":true
"cli":true,
"dockerSock":true
}
}

View File

@ -1,8 +1,9 @@
{
"name": "npmdocker",
"version": "1.0.3",
"version": "1.1.6",
"description": "develop npm modules cross platform with docker",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"bin": {
"npmdocker": "dist/cli.js"
},

View File

@ -4,6 +4,7 @@ import * as paths from "./npmdocker.paths";
export interface IConfig {
baseImage:string;
command:string;
dockerSock:boolean;
exitCode?:number
}
@ -11,7 +12,8 @@ let config:IConfig = plugins.npmextra.dataFor({
toolName:"npmdocker",
defaultSettings: {
baseImage:"hosttoday/ht-docker-node:npmts",
command:"npm test"
command:"npm test",
dockerSock: false
}
});

View File

@ -53,6 +53,11 @@ let buildDockerImage = () => {
silent:true
},() => {
npmdockerOra.text("building Dockerimage...");
// are we creating a build context form project ?
if(process.env.CI == "true"){
npmdockerOra.text("creating build context...");
plugins.smartfile.fs.copySync(paths.cwd,paths.buildContextDir);
}
plugins.shelljs.exec(`docker build -f ${paths.dockerfile} -t ${dockerData.imageTag} ${paths.assets}`,{
silent:true
},() => {
@ -70,18 +75,28 @@ let runDockerImage = () => {
let done = plugins.q.defer();
npmdockerOra.text("starting Container...");
npmdockerOra.end();
config.exitCode = plugins.shelljs.exec(`docker run -v ${paths.cwd}:/workspace --name ${dockerData.containerName} ${dockerData.imageTag}`).code;
// Are we mounting the project directory?
let dockerProjectMountString:string = "";
if(process.env.CI != "true"){
dockerProjectMountString = `-v ${paths.cwd}:/workspace`
};
// Are we mounting docker.sock?
let dockerSockString:string = "";
if(config.dockerSock){
dockerSockString = `-v /var/run/docker.sock:/var/run/docker.sock`
};
plugins.beautylog.log("now running Dockerimage");
config.exitCode = plugins.shelljs.exec(`docker run ${dockerProjectMountString} ${dockerSockString} --name ${dockerData.containerName} ${dockerData.imageTag}`).code;
done.resolve();
return done.promise;
};
let deleteDockerContainter = () => {
let deleteDockerContainer = () => {
let done = plugins.q.defer();
plugins.shelljs.exec(`docker rm ${dockerData.containerName}`,{
plugins.shelljs.exec(`docker rm -f ${dockerData.containerName}`,{
silent:true
});
done.resolve();
plugins.beautylog.ok("removed test container!");
return done.promise
};
@ -91,22 +106,48 @@ let deleteDockerImage = () => {
silent:true
});
done.resolve();
plugins.beautylog.ok("removed test image!");
plugins.beautylog.ok("Cleaned up!");
return done.promise
};
let deleteBuildContext = () => {
let done = plugins.q.defer();
plugins.smartfile.fs.remove(paths.buildContextDir)
.then(done.resolve);
return done.promise;
};
let preClean = () => {
let done = plugins.q.defer();
deleteDockerImage()
.then(deleteDockerContainer)
.then(() => {
plugins.beautylog.ok("ensured clean Docker environment!");
done.resolve();
});
};
let postClean = () => {
let done = plugins.q.defer();
deleteDockerContainer()
.then(deleteDockerImage)
.then(deleteBuildContext)
.then(() => {
plugins.beautylog.ok("cleaned up!");
done.resolve();
});
}
export let run = (configArg) => {
let done = plugins.q.defer();
config = configArg;
checkDocker()
.then(preClean)
.then(buildDockerFile)
.then(buildDockerImage)
.then(runDockerImage)
.then(deleteDockerContainter)
.then(deleteDockerImage)
.then(postClean)
.then(() => {
done.resolve(config);
})

View File

@ -2,7 +2,12 @@ import * as plugins from "./npmdocker.plugins";
// directories
export let cwd = process.cwd();
export let packageBase = plugins.path.join(__dirname,"../");
export let assets = plugins.path.join(packageBase,"assets/");
export let packageBase = plugins.path.join(__dirname, "../");
export let assets = plugins.path.join(packageBase, "assets/");
plugins.smartfile.fs.ensureDirSync(assets);
export let dockerfile = plugins.path.join(assets,"Dockerfile");
export let buildContextDir = plugins.path.join(assets,"buildContextDir");
plugins.smartfile.fs.ensureDirSync(buildContextDir);
// files
export let dockerfile = plugins.path.join(assets, "Dockerfile");

View File

@ -16,7 +16,7 @@ export let dockerfileSnippet = (optionsArg:IDockerfileSnippet):string => {
};
return plugins.smartstring.indent.normalize(`
FROM ${optionsArg.baseImage}
RUN mkdir /workspace
COPY ./buildContextDir /workspace
WORKDIR /workspace
ENV CI=true
CMD [${commandString}];