mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 23:45:48 +01:00
♻️ Change Docker instance to singleton
This commit is contained in:
19
src/pages/api/docker/DockerSingleton.tsx
Normal file
19
src/pages/api/docker/DockerSingleton.tsx
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user