mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: add DOCKER_HOST support
This commit is contained in:
@@ -33,6 +33,18 @@ async function detectCapabilities(): Promise<SystemCapabilities> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const parseDockerHost = (dockerHost?: string) => {
|
||||||
|
const match = dockerHost?.match(/^(ssh|http|https):\/\/([^:]+)(?::(\d+))?$/);
|
||||||
|
if (match) {
|
||||||
|
const protocol = match[1] as "ssh" | "http" | "https";
|
||||||
|
const host = match[2];
|
||||||
|
const port = match[3] ? parseInt(match[3], 10) : undefined;
|
||||||
|
return { protocol, host, port };
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if Docker is available by:
|
* Checks if Docker is available by:
|
||||||
* 1. Checking if /var/run/docker.sock exists and is accessible
|
* 1. Checking if /var/run/docker.sock exists and is accessible
|
||||||
@@ -40,9 +52,7 @@ async function detectCapabilities(): Promise<SystemCapabilities> {
|
|||||||
*/
|
*/
|
||||||
async function detectDocker(): Promise<boolean> {
|
async function detectDocker(): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await fs.access("/var/run/docker.sock");
|
const docker = new Docker(parseDockerHost(process.env.DOCKER_HOST));
|
||||||
|
|
||||||
const docker = new Docker();
|
|
||||||
await docker.ping();
|
await docker.ping();
|
||||||
|
|
||||||
logger.info("Docker capability: enabled");
|
logger.info("Docker capability: enabled");
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import Docker from "dockerode";
|
|||||||
import { and, eq, ne } from "drizzle-orm";
|
import { and, eq, ne } from "drizzle-orm";
|
||||||
import { ConflictError, InternalServerError, NotFoundError } from "http-errors-enhanced";
|
import { ConflictError, InternalServerError, NotFoundError } from "http-errors-enhanced";
|
||||||
import slugify from "slugify";
|
import slugify from "slugify";
|
||||||
import { getCapabilities } from "../../core/capabilities";
|
import { getCapabilities, parseDockerHost } from "../../core/capabilities";
|
||||||
import { db } from "../../db/db";
|
import { db } from "../../db/db";
|
||||||
import { volumesTable } from "../../db/schema";
|
import { volumesTable } from "../../db/schema";
|
||||||
import { toMessage } from "../../utils/errors";
|
import { toMessage } from "../../utils/errors";
|
||||||
@@ -277,7 +277,8 @@ const getContainersUsingVolume = async (name: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const docker = new Docker();
|
const docker = new Docker(parseDockerHost(process.env.DOCKER_HOST));
|
||||||
|
|
||||||
const containers = await docker.listContainers({ all: true });
|
const containers = await docker.listContainers({ all: true });
|
||||||
|
|
||||||
const usingContainers = [];
|
const usingContainers = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user