mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
feat: Add server-level GPU support for Docker Swarm deployments and API endpoint for setup
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
|||||||
import type { Session, User } from "lucia";
|
import type { Session, User } from "lucia";
|
||||||
import superjson from "superjson";
|
import superjson from "superjson";
|
||||||
import { ZodError } from "zod";
|
import { ZodError } from "zod";
|
||||||
|
import { setupGPUSupport } from '@dokploy/server/src/utils/gpu-setup';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1. CONTEXT
|
* 1. CONTEXT
|
||||||
@@ -208,3 +209,10 @@ export const adminProcedure = t.procedure.use(({ ctx, next }) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const appRouter = t.router({
|
||||||
|
setupGPU: t.procedure.mutation(async () => {
|
||||||
|
await setupGPUSupport();
|
||||||
|
return { success: true };
|
||||||
|
}),
|
||||||
|
});
|
||||||
@@ -37,3 +37,6 @@ export const paths = (isServer = false) => {
|
|||||||
REGISTRY_PATH: `${BASE_PATH}/registry`,
|
REGISTRY_PATH: `${BASE_PATH}/registry`,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const GPU_ENABLED = process.env.GPU_ENABLED === 'true';
|
||||||
|
export const GPU_RESOURCE_NAME = 'DOCKER_RESOURCE_GPU';
|
||||||
9
packages/server/src/utils/gpu-setup.ts
Normal file
9
packages/server/src/utils/gpu-setup.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import { docker } from '../constants';
|
||||||
|
|
||||||
|
export async function setupGPUSupport() {
|
||||||
|
await docker.swarmUpdate({
|
||||||
|
TaskDefaults: {
|
||||||
|
GenericResources: [{ DiscreteResourceSpec: { Kind: 'gpu', Value: 1 } }]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user