Compare commits

...

120 Commits

Author SHA1 Message Date
ac386f01e0 1.2.40 2021-09-30 11:14:44 +02:00
08ead4258f fix(core): update 2021-09-30 11:14:43 +02:00
f930f3a6a7 1.2.39 2019-05-28 11:31:40 +02:00
b6d4a76c70 fix(core): update 2019-05-28 11:31:39 +02:00
9a7ecd27e5 1.2.38 2019-05-27 15:50:38 +02:00
11b70b0ddf fix(core): update 2019-05-27 15:50:38 +02:00
79f8cb5e0e 1.2.37 2019-05-27 13:14:12 +02:00
3e1286b9ac fix(core): update 2019-05-27 13:14:12 +02:00
a8ae886959 1.2.36 2019-05-21 17:43:38 +02:00
da1c977a62 fix(core): update 2019-05-21 17:43:37 +02:00
b99b55a05b 1.2.35 2019-05-21 17:41:25 +02:00
133bf0abe5 fix(core): update 2019-05-21 17:41:25 +02:00
df260bbab9 1.2.34 2019-05-21 17:35:37 +02:00
080bd2bc48 fix(core): update 2019-05-21 17:35:36 +02:00
a0032b8168 1.2.33 2019-05-12 18:52:23 +02:00
a09efd1125 fix(core): update 2019-05-12 18:52:23 +02:00
4ce28c7979 1.2.32 2019-05-12 18:30:33 +02:00
415eaea56e fix(bin name): change from npmdocker to tsdocker 2019-05-12 18:30:32 +02:00
bde4597dd9 1.2.31 2019-05-10 17:09:51 +02:00
80946d4f0c fix(core): update 2019-05-10 17:09:50 +02:00
2155e886ef 1.2.30 2019-05-10 11:46:38 +02:00
8b61a90b5f fix(core): update 2019-05-10 11:46:37 +02:00
f48eadc814 1.2.29 2019-05-10 11:46:00 +02:00
9bdaaa0c30 fix(core): update 2019-05-10 11:45:59 +02:00
5f681ff237 fix(core): update 2019-05-10 11:45:20 +02:00
889a3fdc5a 1.2.28 2019-05-09 10:06:59 +02:00
565c002127 fix(core): update 2019-05-09 10:06:59 +02:00
6fec1a00ea 1.2.27 2018-10-29 01:09:46 +01:00
e1f2c28718 fix(ci): remove npmts from build process 2018-10-29 01:09:45 +01:00
9efab07424 1.2.26 2018-10-29 01:07:40 +01:00
18d16feaa9 fix(core): update 2018-10-29 01:07:39 +01:00
df09ff0f9b 1.2.25 2018-10-28 21:40:32 +01:00
7b50ceb69f fix(clean): images are now cleaned in a more thorough way 2018-10-28 21:40:31 +01:00
d1fd76e8d0 1.2.24 2018-09-16 23:14:33 +02:00
b71fa1bc36 fix(core): update 2018-09-16 23:14:33 +02:00
068d28b95d 1.2.23 2018-09-16 21:08:14 +02:00
ecb458f5cd fix(dependencies): update 2018-09-16 21:08:13 +02:00
9f6fb8aedd 1.2.22 2018-07-21 13:32:51 +02:00
f21df13b7c fix(update to latest standards): update 2018-07-21 13:32:51 +02:00
9c56942739 1.2.21 2018-05-18 13:22:08 +02:00
5f4ab33069 1.2.20 2018-05-18 13:17:52 +02:00
14761a442e fix(ci): add build command to package.json 2018-05-18 13:17:52 +02:00
c4ee967ca9 1.2.19 2018-05-18 13:09:14 +02:00
551b8d0cde fix(package): include npmdocker with npm @gitzone scope 2018-05-18 13:09:14 +02:00
4f23b61e14 update description 2018-01-24 23:51:31 +01:00
799320492a 1.2.18 2017-10-13 18:06:16 +02:00
d2cd294b36 now cleaning up correctly 2017-10-13 18:06:12 +02:00
d3d3363e1b 1.2.17 2017-10-13 17:50:34 +02:00
ccd2cb6cbd update 2017-10-13 17:50:31 +02:00
0b0642f9e3 1.2.16 2017-10-13 16:44:31 +02:00
34753a4ae0 fix docker testing 2017-10-13 16:44:25 +02:00
977ecabb41 1.2.15 2017-10-07 16:48:47 +02:00
6d9d040a8d update ci 2017-10-07 16:48:44 +02:00
b2c08b7221 1.2.14 2017-10-07 14:15:35 +02:00
73b1a73719 update Analytics 2017-10-07 14:15:29 +02:00
449512e156 1.2.13 2017-10-07 14:02:27 +02:00
758e677bab update dependencies 2017-10-07 14:02:24 +02:00
42ffb4a8dd 1.2.12 2017-07-16 13:58:48 +02:00
9176b56035 update dependencies and greeting 2017-07-16 13:58:41 +02:00
b3d78f8ce5 1.2.11 2017-04-21 13:44:25 +02:00
b6a6aac8e5 now includes smartanalytics 2017-04-21 13:44:18 +02:00
32f5ead4f4 1.2.10 2017-04-20 21:57:47 +02:00
c29a261cb6 update to latest standards 2017-04-20 21:57:44 +02:00
de57d45947 1.2.9 2017-04-02 14:54:18 +02:00
00bf1532ca update readme 2017-04-02 14:54:15 +02:00
38fc672bf6 update ci 2017-04-02 14:51:38 +02:00
83771df11d 1.2.8 2017-04-02 14:48:27 +02:00
822e480bdf fix command execution 2017-04-02 14:48:23 +02:00
77c6ef99c1 1.2.7 2017-03-29 01:49:32 +02:00
8e3991c121 update gitlab ci yml 2017-03-29 01:49:27 +02:00
77477587b8 1.2.6 2017-03-29 01:04:43 +02:00
c7e32d6990 update ci 2017-03-29 01:04:25 +02:00
da1c2167d3 1.2.5 2017-03-29 01:01:42 +02:00
d55f7ef7f2 now running async and a lot faster 2017-03-29 01:01:37 +02:00
82f4fcceac 1.2.4 2017-02-12 16:04:30 +01:00
aa3b85314d added speedtest 2017-02-12 16:04:27 +01:00
b5145294bd add removing volumes 2017-02-12 15:17:59 +01:00
d25decd15d 1.2.3 2017-02-11 23:37:06 +01:00
abf5cd1e24 added clean --all 2017-02-11 23:37:01 +01:00
9b8636b472 1.2.2 2017-02-11 20:23:13 +01:00
eab75f03da update dependencies and README 2017-02-11 20:23:10 +01:00
74374e99d7 1.2.1 2016-08-04 22:36:05 +02:00
52294de14f remove unnecessary dependencies 2016-08-04 22:36:00 +02:00
4f395850bc 1.2.0 2016-08-04 22:25:21 +02:00
8778324e5b now supports qenv 2016-08-04 22:25:15 +02:00
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
Phil Kunz
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
00e915dc4d 1.0.3 2016-07-20 00:40:44 +02:00
687417c03d now fully working 2016-07-20 00:40:37 +02:00
0157ca94e4 wire up cli use 2016-07-19 19:53:09 +02:00
c07fa65341 1.0.2 2016-07-19 19:22:17 +02:00
778afb04cb added test folder to gitignore 2016-07-19 19:22:12 +02:00
617aec88cc removed test 2016-07-19 19:21:52 +02:00
ca0ecd4e93 now working 2016-07-19 19:21:06 +02:00
2d5054be0b update docker handling 2016-07-19 02:10:36 +02:00
ddfd314a18 improve path management 2016-07-19 02:03:54 +02:00
8c5cf3485a improve confighandling 2016-07-19 00:59:57 +02:00
Phil Kunz
e222456431 start Docker configuration 2016-07-19 00:37:13 +02:00
Phil Kunz
c5413ca11d start docker integration 2016-07-18 20:48:34 +02:00
030c3ec00d update 2016-07-17 19:00:53 +02:00
22 changed files with 28619 additions and 39 deletions

25
.gitignore vendored
View File

@ -1,4 +1,23 @@
node_modules/
coverage/
docs/
.nogit/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
# custom
test

View File

@ -1,35 +1,69 @@
image: hosttoday/ht-docker-node:npmts
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:dind
stages:
- mirror
- test
- release
- trigger
- pages
testLEGACY:
stage: test
mirror:
image: hosttoday/ht-docker-node:npmci
stage: mirror
script:
- npmci test legacy
- npmci git mirror
tags:
- docker
testLTS:
test:
stage: test
script:
- npmci test lts
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
- npmci node install stable
- npmci npm install
- npmci npm test
tags:
- docker
- lossless
- priv
release:
stage: release
environment: npmjs-com_registry
script:
- npmci publish
- npmci npm prepare
- npmci npm publish
only:
- tags
tags:
- docker
- lossless
- priv
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
- lossless
- priv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
script:
- npmci command npm install -g @gitzone/tsdoc
- npmci command tsdoc
only:
- tags
tags:
- docker
artifacts:
expire_in: 1 week
paths:
- public

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}

4
Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM hosttoday/ht-docker-node:stable
LABEL author="Lossless GmbH <office@lossless.com>"
RUN yarn global add npmci npmdocker npmts ts-node

View File

@ -1,5 +0,0 @@
# npmdocker
develop npm modules cross platform with docker
## Usage
npmdocker looks for a npmextra.json at the root of your directory and looks at the npmdocker portion of it.

6
assets/Dockerfile Normal file
View File

@ -0,0 +1,6 @@
FROM hosttoday/ht-docker-node:npmci
RUN yarn global add @gitzone/tsdocker
COPY ./ /workspace
WORKDIR /workspace
ENV CI=true
CMD ["tsdocker","runinside"];

3
cli.js Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
process.env.CLI_CALL = 'true';
require('./dist/index');

4
cli.ts.js Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env node
process.env.CLI_CALL = 'true';
require('@gitzone/tsrun');
require('./ts/index');

0
dist/index.d.ts vendored
View File

1
dist/index.js vendored
View File

@ -1 +0,0 @@
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIn0=

20
npmextra.json Normal file
View File

@ -0,0 +1,20 @@
{
"npmts": {
"mode": "default",
"cli": true
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "gitzone",
"gitrepo": "npmdocker",
"shortDescription": "develop npm modules cross platform with docker",
"npmPackagename": "@gitzone/npmdocker",
"license": "MIT"
}
}
}

28061
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,27 @@
{
"name": "npmdocker",
"version": "1.0.1",
"name": "@gitzone/tsdocker",
"version": "1.2.40",
"private": false,
"description": "develop npm modules cross platform with docker",
"main": "dist/index.js",
"directories": {
"test": "test"
"typings": "dist/index.d.ts",
"bin": {
"tsdocker": "cli.js"
},
"scripts": {
"test": "(npmts)"
"test": "(npm run clean && npm run setupCheck && npm run testStandard && npm run testSpeed)",
"build": "(tsbuild)",
"testStandard": "(cd test/ && node ../cli.ts.js)",
"testSpeed": "(cd test/ && node ../cli.ts.js speedtest)",
"testClean": "(cd test/ && node ../cli.ts.js clean --all)",
"testVscode": "(cd test/ && node ../cli.ts.js vscode)",
"clean": "(rm -rf test/)",
"compile": "(npmts --notest)",
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/pushrocks/npmdocker.git"
"url": "git+ssh://git@gitlab.com/gitzone/npmdocker.git"
},
"keywords": [
"docker"
@ -19,19 +29,32 @@
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/npmdocker/issues"
"url": "https://gitlab.com/gitzone/npmdocker/issues"
},
"homepage": "https://gitlab.com/pushrocks/npmdocker#README",
"homepage": "https://gitlab.com/gitzone/npmdocker#README",
"devDependencies": {
"npmts-g": "^5.2.6",
"should": "^9.0.2",
"typings-test": "^1.0.1"
"@gitzone/tsbuild": "^2.1.27",
"@gitzone/tsrun": "^1.2.17",
"@gitzone/tstest": "^1.0.57",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^16.10.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"beautylog": "^5.0.13",
"q": "^1.4.1",
"rxjs": "^5.0.0-beta.10",
"smartfile": "^4.0.10",
"typings-global": "^1.0.6"
"@pushrocks/npmextra": "^3.0.9",
"@pushrocks/projectinfo": "^4.0.5",
"@pushrocks/qenv": "^4.0.10",
"@pushrocks/smartanalytics": "^2.0.15",
"@pushrocks/smartcli": "^3.0.14",
"@pushrocks/smartfile": "^8.0.10",
"@pushrocks/smartlog": "^2.0.44",
"@pushrocks/smartlog-destination-local": "^8.0.8",
"@pushrocks/smartlog-source-ora": "^1.0.9",
"@pushrocks/smartopen": "^1.0.22",
"@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartshell": "^2.0.28",
"@pushrocks/smartstring": "^3.0.24",
"@types/shelljs": "^0.8.9"
}
}

View File

@ -0,0 +1,4 @@
import * as plugins from './tsdocker.plugins';
import * as cli from './tsdocker.cli';
cli.run();

90
ts/tsdocker.cli.ts Normal file
View File

@ -0,0 +1,90 @@
import * as plugins from './tsdocker.plugins';
import * as paths from './tsdocker.paths';
// modules
import * as ConfigModule from './tsdocker.config';
import * as DockerModule from './tsdocker.docker';
import { logger, ora } from './tsdocker.logging';
const tsdockerCli = new plugins.smartcli.Smartcli();
export let run = () => {
tsdockerCli.standardTask().subscribe(async argvArg => {
const configArg = await ConfigModule.run().then(DockerModule.run);
if (configArg.exitCode === 0) {
logger.log('success', 'container ended all right!');
} else {
logger.log('error', `container ended with error! Exit Code is ${configArg.exitCode}`);
process.exit(1);
}
});
/**
* this command is executed inside docker and meant for use from outside docker
*/
tsdockerCli.addCommand('runinside').subscribe(async argvArg => {
logger.log('ok', 'Allright. We are now in Docker!');
ora.text('now trying to run your specified command');
const configArg = await ConfigModule.run();
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
ora.stop();
await smartshellInstance.exec(configArg.command).then(response => {
if (response.exitCode !== 0) {
process.exit(1);
}
});
});
tsdockerCli.addCommand('clean').subscribe(async argvArg => {
ora.text('cleaning up docker env...');
if (argvArg.all) {
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
ora.text('killing any running docker containers...');
await smartshellInstance.exec(`docker kill $(docker ps -q)`);
ora.text('removing stopped containers...');
await smartshellInstance.exec(`docker rm $(docker ps -a -q)`);
ora.text('removing images...');
await smartshellInstance.exec(`docker rmi -f $(docker images -q -f dangling=true)`);
ora.text('removing all other images...');
await smartshellInstance.exec(`docker rmi $(docker images -a -q)`);
ora.text('removing all volumes...');
await smartshellInstance.exec(`docker volume rm $(docker volume ls -f dangling=true -q)`);
}
ora.finishSuccess('docker environment now is clean!');
});
tsdockerCli.addCommand('speedtest').subscribe(async argvArg => {
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
logger.log('ok', 'Starting speedtest');
await smartshellInstance.exec(
`docker pull tianon/speedtest && docker run --rm tianon/speedtest --accept-license --accept-gdpr`
);
});
tsdockerCli.addCommand('vscode').subscribe(async argvArg => {
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
logger.log('ok', `Starting vscode in cwd ${paths.cwd}`);
await smartshellInstance.execAndWaitForLine(
`docker run -p 127.0.0.1:8443:8443 -v "${
paths.cwd
}:/home/coder/project" registry.gitlab.com/hosttoday/ht-docker-vscode --allow-http --no-auth`,
/Connected to shared process/
);
await plugins.smartopen.openUrl('testing-vscode.git.zone:8443');
});
tsdockerCli.startParse();
};

37
ts/tsdocker.config.ts Normal file
View File

@ -0,0 +1,37 @@
import * as plugins from './tsdocker.plugins';
import * as paths from './tsdocker.paths';
export interface IConfig {
baseImage: string;
command: string;
dockerSock: boolean;
exitCode?: number;
keyValueObject: {[key: string]: any};
}
const getQenvKeyValueObject = async () => {
let qenvKeyValueObjectArray: { [key: string]: string | number };
if (plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) {
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObject;
} else {
qenvKeyValueObjectArray = {};
}
return qenvKeyValueObjectArray;
};
const buildConfig = async (qenvKeyValueObjectArg: { [key: string]: string | number }) => {
const npmextra = new plugins.npmextra.Npmextra(paths.cwd);
const config = npmextra.dataFor<IConfig>('npmdocker', {
baseImage: 'hosttoday/ht-docker-node:npmdocker',
init: 'rm -rf node_nodules/ && yarn install',
command: 'npmci npm test',
dockerSock: false,
keyValueObject: qenvKeyValueObjectArg
});
return config;
};
export let run = async (): Promise<IConfig> => {
const config = await getQenvKeyValueObject().then(buildConfig);
return config;
};

169
ts/tsdocker.docker.ts Normal file
View File

@ -0,0 +1,169 @@
import * as plugins from './tsdocker.plugins';
import * as paths from './tsdocker.paths';
import * as snippets from './tsdocker.snippets';
import { logger, ora } from './tsdocker.logging';
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
// interfaces
import { IConfig } from './tsdocker.config';
let config: IConfig;
/**
* the docker data used to build the internal testing container
*/
const dockerData = {
imageTag: 'npmdocker-temp-image:latest',
containerName: 'npmdocker-temp-container',
dockerProjectMountString: '',
dockerSockString: '',
dockerEnvString: ''
};
/**
* check if docker is available
*/
const checkDocker = () => {
const done = plugins.smartpromise.defer();
ora.text('checking docker...');
if (smartshellInstance.exec('which docker')) {
logger.log('ok', 'Docker found!');
done.resolve();
} else {
done.reject(new Error('docker not found on this machine'));
}
return done.promise;
};
/**
* builds the Dockerfile according to the config in the project
*/
const buildDockerFile = () => {
const done = plugins.smartpromise.defer();
ora.text('building Dockerfile...');
const dockerfile: string = snippets.dockerfileSnippet({
baseImage: config.baseImage,
command: config.command
});
logger.log('info', `Base image is: ${config.baseImage}`);
logger.log('info', `Command is: ${config.command}`);
plugins.smartfile.memory.toFsSync(dockerfile, plugins.path.join(paths.cwd, 'npmdocker'));
logger.log('ok', 'Dockerfile created!');
ora.stop();
done.resolve();
return done.promise;
};
/**
* builds the Dockerimage from the built Dockerfile
*/
const buildDockerImage = async () => {
logger.log('info', 'pulling latest base image from registry...');
await smartshellInstance.exec(`docker pull ${config.baseImage}`);
ora.text('building Dockerimage...');
const execResult = await smartshellInstance.execSilent(
`docker build -f npmdocker -t ${dockerData.imageTag} ${paths.cwd}`
);
if (execResult.exitCode !== 0) {
console.log(execResult.stdout);
process.exit(1);
}
logger.log('ok', 'Dockerimage built!');
};
const buildDockerProjectMountString = async () => {
if (process.env.CI !== 'true') {
dockerData.dockerProjectMountString = `-v ${paths.cwd}:/workspace`;
}
};
/**
* builds an environment string that docker cli understands
*/
const buildDockerEnvString = async () => {
for (const key of Object.keys(config.keyValueObject)) {
const envString = (dockerData.dockerEnvString =
dockerData.dockerEnvString + `-e ${key}=${config.keyValueObject[key]} `);
}
};
/**
* creates string to mount the docker.sock inside the testcontainer
*/
const buildDockerSockString = async () => {
if (config.dockerSock) {
dockerData.dockerSockString = `-v /var/run/docker.sock:/var/run/docker.sock`;
}
};
/**
* creates a container by running the built Dockerimage
*/
const runDockerImage = async () => {
const done = plugins.smartpromise.defer();
ora.text('starting Container...');
ora.stop();
logger.log('info', 'now running Dockerimage');
config.exitCode = (await smartshellInstance.exec(
`docker run ${dockerData.dockerProjectMountString} ${dockerData.dockerSockString} ${
dockerData.dockerEnvString
} --name ${dockerData.containerName} ${dockerData.imageTag}`
)).exitCode;
};
/**
* cleans up: deletes the test container
*/
const deleteDockerContainer = async () => {
await smartshellInstance.execSilent(`docker rm -f ${dockerData.containerName}`);
};
/**
* cleans up deletes the test image
*/
const deleteDockerImage = async () => {
await smartshellInstance.execSilent(`docker rmi ${dockerData.imageTag}`).then(async response => {
if (response.exitCode !== 0) {
console.log(response.stdout);
}
});
};
const preClean = async () => {
await deleteDockerImage()
.then(deleteDockerContainer)
.then(async () => {
logger.log('ok', 'ensured clean Docker environment!');
});
};
const postClean = async () => {
await deleteDockerContainer()
.then(deleteDockerImage)
.then(async () => {
logger.log('ok', 'cleaned up!');
});
plugins.smartfile.fs.removeSync(paths.npmdockerFile);
};
export let run = async (configArg: IConfig): Promise<IConfig> => {
config = configArg;
const resultConfig = await checkDocker()
.then(preClean)
.then(buildDockerFile)
.then(buildDockerImage)
.then(buildDockerProjectMountString)
.then(buildDockerEnvString)
.then(buildDockerSockString)
.then(runDockerImage)
.then(postClean)
.catch(err => {
console.log(err);
});
return config;
};

17
ts/tsdocker.logging.ts Normal file
View File

@ -0,0 +1,17 @@
import * as plugins from './tsdocker.plugins';
export const logger = new plugins.smartlog.Smartlog({
logContext: {
company: 'Some Company',
companyunit: 'Some CompanyUnit',
containerName: 'Some Containername',
environment: 'local',
runtime: 'node',
zone: 'gitzone'
},
minimumLogLevel: 'silly'
});
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
export const ora = new plugins.smartlogSouceOra.SmartlogSourceOra();

8
ts/tsdocker.paths.ts Normal file
View File

@ -0,0 +1,8 @@
import * as plugins from './tsdocker.plugins';
// directories
export let cwd = process.cwd();
export let packageBase = plugins.path.join(__dirname, '../');
export let assets = plugins.path.join(packageBase, 'assets/');
plugins.smartfile.fs.ensureDirSync(assets);
export let npmdockerFile = plugins.path.join(cwd, 'npmdocker');

30
ts/tsdocker.plugins.ts Normal file
View File

@ -0,0 +1,30 @@
// pushrocks scope
import * as npmextra from '@pushrocks/npmextra';
import * as path from 'path';
import * as projectinfo from '@pushrocks/projectinfo';
import * as smartpromise from '@pushrocks/smartpromise';
import * as qenv from '@pushrocks/qenv';
import * as smartcli from '@pushrocks/smartcli';
import * as smartfile from '@pushrocks/smartfile';
import * as smartlog from '@pushrocks/smartlog';
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
import * as smartlogSouceOra from '@pushrocks/smartlog-source-ora';
import * as smartopen from '@pushrocks/smartopen';
import * as smartshell from '@pushrocks/smartshell';
import * as smartstring from '@pushrocks/smartstring';
export {
npmextra,
path,
projectinfo,
smartpromise,
qenv,
smartcli,
smartfile,
smartlog,
smartlogDestinationLocal,
smartlogSouceOra,
smartopen,
smartshell,
smartstring
};

37
ts/tsdocker.snippets.ts Normal file
View File

@ -0,0 +1,37 @@
import * as plugins from './tsdocker.plugins';
export interface IDockerfileSnippet {
baseImage: string;
command: string;
}
let getMountSolutionString = (optionsArg: IDockerfileSnippet) => {
if (process.env.CI) {
return 'COPY ./ /workspace';
} else {
return '# not copying workspcae since not in CI';
}
};
let getGlobalPreparationString = (optionsArg: IDockerfileSnippet) => {
if (optionsArg.baseImage !== 'hosttoday/ht-docker-node:npmdocker') {
return 'RUN npm install -g npmdocker';
} else {
return '# not installing npmdocker since it is included in the base image';
}
};
export let dockerfileSnippet = (optionsArg: IDockerfileSnippet): string => {
return plugins.smartstring.indent.normalize(
`
FROM ${optionsArg.baseImage}
# For info about what npmdocker does read the docs at https://gitzone.github.io/npmdocker
${getGlobalPreparationString(optionsArg)}
${getMountSolutionString(optionsArg)}
WORKDIR /workspace
ENV CI=true
ENTRYPOINT ["npmdocker"]
CMD ["runinside"]
`
);
};

17
tslint.json Normal file
View File

@ -0,0 +1,17 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}