feat: Add server-level GPU support for Docker Swarm deployments and API endpoint for setup

This commit is contained in:
vishalkadam47
2024-10-17 15:45:27 +05:30
parent fe19cdb5e4
commit 15a76d2639
3 changed files with 20 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ import {
import type { Session, User } from "lucia";
import superjson from "superjson";
import { ZodError } from "zod";
import { setupGPUSupport } from '@dokploy/server/src/utils/gpu-setup';
/**
* 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 };
}),
});

View File

@@ -37,3 +37,6 @@ export const paths = (isServer = false) => {
REGISTRY_PATH: `${BASE_PATH}/registry`,
};
};
export const GPU_ENABLED = process.env.GPU_ENABLED === 'true';
export const GPU_RESOURCE_NAME = 'DOCKER_RESOURCE_GPU';

View File

@@ -0,0 +1,9 @@
import { docker } from '../constants';
export async function setupGPUSupport() {
await docker.swarmUpdate({
TaskDefaults: {
GenericResources: [{ DiscreteResourceSpec: { Kind: 'gpu', Value: 1 } }]
}
});
}