Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
e50b028c00 | |||
867dda8e7c | |||
d12d595f21 | |||
6117228ea4 | |||
b6b584f808 | |||
48fe6ce0a8 | |||
55acb39071 | |||
f7b17a4684 | |||
d95f6c8e7f | |||
001cdadb6b | |||
82655623d1 | |||
ea117bc391 |
125
.gitlab-ci.yml
125
.gitlab-ci.yml
@ -1,62 +1,141 @@
|
||||
image: hosttoday/ht-docker-dbase:npmci
|
||||
services:
|
||||
- docker:dind
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .yarn/
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- npmci prepare docker-gitlab
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
test:
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
sast:
|
||||
stage: security
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
|
||||
variables:
|
||||
DOCKER_DRIVER: overlay2
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
|
||||
--volume "$PWD:/code"
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
|
||||
artifacts:
|
||||
reports:
|
||||
sast: gl-sast-report.json
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testSTABLE:
|
||||
image: hosttoday/ht-docker-dbase:npmci
|
||||
services:
|
||||
- docker:dind
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
release:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish npm
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: trigger
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- priv
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: pages
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command yarn global add npmpage
|
||||
- npmci command npmpage --publish gitlab
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
|
@ -1,8 +1,4 @@
|
||||
{
|
||||
"npmts": {
|
||||
"mode": "default",
|
||||
"coverageTreshold": 10
|
||||
},
|
||||
"npmdocker": {
|
||||
"baseImage": "hosttoday/ht-docker-node:npmci",
|
||||
"command":
|
||||
@ -10,6 +6,8 @@
|
||||
"dockerSock": true
|
||||
},
|
||||
"npmci": {
|
||||
"globalNpmTools": ["npmts", "npmdocker"]
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public",
|
||||
"npmRegistryUrl": "registry.npmjs.org"
|
||||
}
|
||||
}
|
||||
|
896
package-lock.json
generated
896
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@ -1,12 +1,13 @@
|
||||
{
|
||||
"name": "@mojoio/docker",
|
||||
"version": "1.0.26",
|
||||
"version": "1.0.32",
|
||||
"description": "easy communication with docker remote api from node, TypeScript ready",
|
||||
"private": false,
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "tsrun test/test.ts",
|
||||
"build": "(npmts --notest && npmdocker)"
|
||||
"test": "tstest test/",
|
||||
"build": "tsbuild"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -26,18 +27,19 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/dockersock#README",
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^3.0.4",
|
||||
"@pushrocks/smartlog": "^2.0.9",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartrequest": "^1.1.14",
|
||||
"rxjs": "^6.3.3"
|
||||
"@pushrocks/lik": "^3.0.10",
|
||||
"@pushrocks/smartlog": "^2.0.19",
|
||||
"@pushrocks/smartpromise": "^3.0.2",
|
||||
"@pushrocks/smartrequest": "^1.1.16",
|
||||
"rxjs": "^6.5.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsrun": "^1.1.17",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.12.18",
|
||||
"tslint": "^5.12.0",
|
||||
"tslint-config-prettier": "^1.17.0"
|
||||
},
|
||||
"private": false
|
||||
"@gitzone/tsbuild": "^2.1.11",
|
||||
"@gitzone/tsrun": "^1.2.8",
|
||||
"@gitzone/tstest": "^1.0.24",
|
||||
"@pushrocks/tapbundle": "^3.0.11",
|
||||
"@types/node": "^12.7.1",
|
||||
"tslint": "^5.18.0",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
}
|
||||
}
|
||||
|
@ -13,12 +13,11 @@ tap.test('should list containers', async () => {
|
||||
console.log(containers);
|
||||
});
|
||||
|
||||
|
||||
tap.skip.test('should pull an image from imagetag', async () => {
|
||||
// await testDockerHost.pullImage('hosttoday/ht-docker-node:npmci');
|
||||
});
|
||||
|
||||
tap.test('should return a change Objservable', async (tools) => {
|
||||
tap.test('should return a change Objservable', async tools => {
|
||||
const testObservable = await testDockerHost.getEventObservable();
|
||||
const subscription = testObservable.subscribe(changeObject => {
|
||||
console.log(changeObject);
|
||||
|
@ -11,9 +11,11 @@ export class DockerContainer {
|
||||
/**
|
||||
* get all containers
|
||||
*/
|
||||
static async getContainers(dockerHostArg: DockerHost): Promise<DockerContainer[]> {
|
||||
public static async getContainers(dockerHostArg: DockerHost): Promise<DockerContainer[]> {
|
||||
const result: DockerContainer[] = [];
|
||||
const response = await dockerHostArg.request('GET', '/containers/json');
|
||||
|
||||
// TODO: Think about getting the config by inpsecting the container
|
||||
for (const containerResult of response.body) {
|
||||
result.push(new DockerContainer(containerResult));
|
||||
}
|
||||
@ -21,13 +23,17 @@ export class DockerContainer {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* gets an container by Id
|
||||
* @param containerId
|
||||
*/
|
||||
static async getContainerById(containerId: string) {
|
||||
public static async getContainerById(containerId: string) {}
|
||||
|
||||
/**
|
||||
* create a container
|
||||
*/
|
||||
public static async create(creationSpecifier: interfaces.IContainerCreationSpecifier) {
|
||||
|
||||
}
|
||||
static async create() {}
|
||||
|
||||
// ========
|
||||
// INSTANCE
|
||||
@ -36,7 +42,7 @@ export class DockerContainer {
|
||||
constructor(dockerContainerObjectArg: any) {
|
||||
Object.keys(dockerContainerObjectArg).forEach(keyArg => {
|
||||
this[keyArg] = dockerContainerObjectArg[keyArg];
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
Id: string;
|
||||
|
@ -37,13 +37,19 @@ export class DockerHost {
|
||||
async getContainers() {
|
||||
const containerArray = await DockerContainer.getContainers(this);
|
||||
return containerArray;
|
||||
};
|
||||
}
|
||||
|
||||
async getEventObservable(): Promise<plugins.rxjs.Observable<any>> {
|
||||
const response = await this.requestStreaming('GET', '/events');
|
||||
return plugins.rxjs.Observable.create(observer => {
|
||||
response.on('data', data => {
|
||||
observer.next(data.toString());
|
||||
const eventString = data.toString();
|
||||
try {
|
||||
const eventObject = JSON.parse(eventString);
|
||||
observer.next(eventObject);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
return () => {
|
||||
response.emit('end');
|
||||
@ -70,7 +76,8 @@ export class DockerHost {
|
||||
async requestStreaming(methodArg: string, routeArg: string, dataArg = {}) {
|
||||
const requestUrl = `${this.sockPath}${routeArg}`;
|
||||
const response = await plugins.smartrequest.request(
|
||||
requestUrl, {
|
||||
requestUrl,
|
||||
{
|
||||
method: methodArg,
|
||||
headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
|
@ -2,13 +2,36 @@ import * as plugins from './dockersock.plugins';
|
||||
import { DockerHost } from './docker.classes.host';
|
||||
|
||||
export class DockerImage {
|
||||
// STATIC
|
||||
public static async createFromRegistry(dockerHostArg: DockerHost, dockerImageTag): Promise<DockerImage> {
|
||||
const resultingImage = new DockerImage();
|
||||
|
||||
return resultingImage;
|
||||
}
|
||||
|
||||
public static async createFromExistingImage(dockerHostArg: DockerHost, dockerImageTag) {}
|
||||
|
||||
// INSTANCE
|
||||
/**
|
||||
* the tags for an image
|
||||
*/
|
||||
tags: string[] = [];
|
||||
public tags: string[] = [];
|
||||
|
||||
static async createFromRegsitry(dockerHostArg: DockerHost): Promise<DockerImage> {
|
||||
const resultingImage = new DockerImage();
|
||||
return resultingImage;
|
||||
/**
|
||||
* returns a boolean wether the image has a upstream image
|
||||
*/
|
||||
public isUpstreamImage (): boolean {
|
||||
// TODO: implement isUpastreamImage
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public async pullLatestImageFromRegistry() : Promise<boolean> {
|
||||
// TODO: implement pullLatestImageFromRegistry
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
import * as plugins from './dockersock.plugins';
|
||||
import * as interfaces from './interfaces';
|
||||
|
||||
import { DockerHost } from './docker.classes.host';
|
||||
|
||||
export class DockerNetwork {
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
import * as plugins from './dockersock.plugins';
|
||||
import * as interfaces from './interfaces';
|
||||
|
||||
import { DockerHost } from './docker.classes.host';
|
||||
|
||||
export class DockerService {
|
||||
|
||||
}
|
@ -4,16 +4,9 @@ import * as smartlog from '@pushrocks/smartlog';
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartrequest from '@pushrocks/smartrequest';
|
||||
|
||||
export {
|
||||
lik,
|
||||
smartlog,
|
||||
smartpromise,
|
||||
smartrequest
|
||||
};
|
||||
export { lik, smartlog, smartpromise, smartrequest };
|
||||
|
||||
// third party
|
||||
import * as rxjs from 'rxjs';
|
||||
|
||||
export {
|
||||
rxjs
|
||||
};
|
||||
export { rxjs };
|
||||
|
@ -1 +1,5 @@
|
||||
export { DockerHost } from './docker.classes.host';
|
||||
export * from './docker.classes.host';
|
||||
export * from './docker.classes.container';
|
||||
export * from './docker.classes.image';
|
||||
export * from './docker.classes.network';
|
||||
export * from './docker.classes.service';
|
||||
|
7
ts/interfaces/container.ts
Normal file
7
ts/interfaces/container.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { DockerNetwork } from '../docker.classes.network';
|
||||
|
||||
export interface IContainerCreationSpecifier {
|
||||
hostname: string;
|
||||
domainName: string;
|
||||
networks?: DockerNetwork[];
|
||||
}
|
@ -1,2 +1,3 @@
|
||||
export * from './container';
|
||||
export * from './label';
|
||||
export * from './port';
|
||||
|
@ -1,2 +1,2 @@
|
||||
// tslint:disable-next-line: interface-over-type-literal
|
||||
export type TLabels = {[key: string]: string };
|
||||
export type TLabels = { [key: string]: string };
|
||||
|
Reference in New Issue
Block a user