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:
|
||||
* 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> {
|
||||
try {
|
||||
await fs.access("/var/run/docker.sock");
|
||||
|
||||
const docker = new Docker();
|
||||
const docker = new Docker(parseDockerHost(process.env.DOCKER_HOST));
|
||||
await docker.ping();
|
||||
|
||||
logger.info("Docker capability: enabled");
|
||||
|
||||
@@ -5,7 +5,7 @@ import Docker from "dockerode";
|
||||
import { and, eq, ne } from "drizzle-orm";
|
||||
import { ConflictError, InternalServerError, NotFoundError } from "http-errors-enhanced";
|
||||
import slugify from "slugify";
|
||||
import { getCapabilities } from "../../core/capabilities";
|
||||
import { getCapabilities, parseDockerHost } from "../../core/capabilities";
|
||||
import { db } from "../../db/db";
|
||||
import { volumesTable } from "../../db/schema";
|
||||
import { toMessage } from "../../utils/errors";
|
||||
@@ -277,7 +277,8 @@ const getContainersUsingVolume = async (name: string) => {
|
||||
}
|
||||
|
||||
try {
|
||||
const docker = new Docker();
|
||||
const docker = new Docker(parseDockerHost(process.env.DOCKER_HOST));
|
||||
|
||||
const containers = await docker.listContainers({ all: true });
|
||||
|
||||
const usingContainers = [];
|
||||
|
||||
Reference in New Issue
Block a user