♻️ Change Docker instance to singleton

This commit is contained in:
Noan
2022-08-23 18:58:10 +02:00
parent 48a5b4d4fd
commit dccfe7e2e3
3 changed files with 23 additions and 5 deletions

View File

@@ -0,0 +1,19 @@
import Docker from 'dockerode';
export default class DockerSingleton extends Docker {
private static dockerInstance: DockerSingleton;
private constructor() {
super({
host: '192.168.1.56',
port: 2376,
});
}
public static getInstance(): DockerSingleton {
if (!this.dockerInstance) {
this.dockerInstance = new this();
}
return this.dockerInstance;
}
}