mirror of
https://github.com/khoaliber/dockhand.git
synced 2026-03-05 13:20:57 +00:00
Initial commit
This commit is contained in:
46
routes/api/environments/detect-socket/+server.ts
Normal file
46
routes/api/environments/detect-socket/+server.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { homedir } from 'node:os';
|
||||
|
||||
interface DetectedSocket {
|
||||
path: string;
|
||||
name: string;
|
||||
exists: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect available Docker sockets on the system
|
||||
*/
|
||||
export const GET: RequestHandler = async () => {
|
||||
const home = homedir();
|
||||
|
||||
// Common socket paths to check
|
||||
const socketPaths: { path: string; name: string }[] = [
|
||||
{ path: '/var/run/docker.sock', name: 'Docker (default)' },
|
||||
{ path: `${home}/.docker/run/docker.sock`, name: 'Docker Desktop' },
|
||||
{ path: `${home}/.orbstack/run/docker.sock`, name: 'OrbStack' },
|
||||
{ path: '/run/docker.sock', name: 'Docker (alternate)' },
|
||||
{ path: `${home}/.colima/default/docker.sock`, name: 'Colima' },
|
||||
{ path: `${home}/.rd/docker.sock`, name: 'Rancher Desktop' },
|
||||
{ path: '/run/user/1000/podman/podman.sock', name: 'Podman (user 1000)' },
|
||||
{ path: `${home}/.local/share/containers/podman/machine/podman.sock`, name: 'Podman Machine' },
|
||||
];
|
||||
|
||||
const detected: DetectedSocket[] = [];
|
||||
|
||||
for (const socket of socketPaths) {
|
||||
if (existsSync(socket.path)) {
|
||||
detected.push({
|
||||
path: socket.path,
|
||||
name: socket.name,
|
||||
exists: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return json({
|
||||
sockets: detected,
|
||||
homedir: home
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user