MCPcopy
hub / github.com/Dokploy/dokploy / setupLocalServer

Function setupLocalServer

packages/server/src/utils/gpu-setup.ts:299–322  ·  view source on GitHub ↗
(daemonConfig: any)

Source from the content-addressed store, hash-verified

297};
298
299const setupLocalServer = async (daemonConfig: any) => {
300 const configFile = `/tmp/docker-daemon-${Date.now()}.json`;
301 await fs.writeFile(configFile, JSON.stringify(daemonConfig, null, 2));
302
303 const setupCommands = [
304 `sudo sh -c '
305 cp ${configFile} /etc/docker/daemon.json &&
306 mkdir -p /etc/nvidia-container-runtime &&
307 sed -i "/swarm-resource/d" /etc/nvidia-container-runtime/config.toml &&
308 echo "swarm-resource = \\"DOCKER_RESOURCE_GPU\\"" >> /etc/nvidia-container-runtime/config.toml &&
309 systemctl daemon-reload &&
310 systemctl restart docker
311 '`,
312 `rm ${configFile}`,
313 ].join(" && ");
314
315 try {
316 await execAsync(setupCommands);
317 } catch {
318 throw new Error(
319 "Failed to configure GPU support. Please ensure you have sudo privileges and try again.",
320 );
321 }
322};
323
324const addGpuLabel = async (nodeId: string, serverId?: string) => {
325 const labelCommand = `docker node update --label-add gpu=true ${nodeId}`;

Callers 1

setupGPUSupportFunction · 0.85

Calls 1

execAsyncFunction · 0.90

Tested by

no test coverage detected