feat(imagestore): now processing images with extraction, retagging, repackaging and long term storage

This commit is contained in:
2024-06-08 15:03:19 +02:00
parent 740f83114c
commit c0cebbe614
13 changed files with 241 additions and 90 deletions

View File

@@ -1,10 +1,12 @@
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import { DockerContainer } from './classes.container.js';
import { DockerNetwork } from './classes.network.js';
import { DockerService } from './classes.service.js';
import { logger } from './logging.js';
import { logger } from './logger.js';
import path from 'path';
import type { DockerImageStore } from './classes.imagestore.js';
import { DockerImageStore } from './classes.imagestore.js';
import { DockerImage } from './classes.image.js';
export interface IAuthData {
serveraddress: string;
@@ -18,6 +20,8 @@ export interface IDockerHostConstructorOptions {
}
export class DockerHost {
public options: IDockerHostConstructorOptions;
/**
* the path where the docker sock can be found
*/
@@ -30,6 +34,12 @@ export class DockerHost {
* @param pathArg
*/
constructor(optionsArg: IDockerHostConstructorOptions) {
this.options = {
...{
imageStoreDir: plugins.path.join(paths.nogitDir, 'temp-docker-image-store'),
},
...optionsArg,
}
let pathToUse: string;
if (optionsArg.dockerSockPath) {
pathToUse = optionsArg.dockerSockPath;
@@ -48,6 +58,17 @@ export class DockerHost {
}
console.log(`using docker sock at ${pathToUse}`);
this.socketPath = pathToUse;
this.imageStore = new DockerImageStore(this, {
bucketDir: null,
localDirPath: this.options.imageStoreDir,
})
}
public async start() {
await this.imageStore.start();
}
public async stop() {
await this.imageStore.stop();
}
/**
@@ -81,6 +102,9 @@ export class DockerHost {
});
}
// ==============
// NETWORKS
// ==============
/**
* gets all networks
*/
@@ -89,9 +113,23 @@ export class DockerHost {
}
/**
*
* create a network
*/
public async createNetwork(optionsArg: Parameters<typeof DockerNetwork.createNetwork>[1]) {
return await DockerNetwork.createNetwork(this, optionsArg);
}
/**
* get a network by name
*/
public async getNetworkByName(networkNameArg: string) {
return await DockerNetwork.getNetworkByName(this, networkNameArg);
}
// ==============
// CONTAINERS
// ==============
/**
* gets all containers
*/
@@ -100,6 +138,10 @@ export class DockerHost {
return containerArray;
}
// ==============
// SERVICES
// ==============
/**
* gets all services
*/
@@ -108,6 +150,24 @@ export class DockerHost {
return serviceArray;
}
// ==============
// IMAGES
// ==============
/**
* get all images
*/
public async getImages() {
return await DockerImage.getImages(this);
}
/**
* get an image by name
*/
public async getImageByName(imageNameArg: string) {
return await DockerImage.getImageByName(this, imageNameArg);
}
/**
*
*/