Skip to content

Commit eb4f7d9

Browse files
authored
Merge pull request #981 from constructive-io/devin/1776320122-pgpm-docker-ollama
feat(pgpm): add --ollama and --gpu flags to pgpm docker
2 parents 97ea77b + 822a015 commit eb4f7d9

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

pgpm/cli/src/commands/docker.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ PostgreSQL Options:
2424
2525
Additional Services:
2626
--minio Include MinIO S3-compatible object storage (API: 9000, Console: 9001)
27+
--ollama Include Ollama LLM inference server (API: 11434)
28+
--gpu Enable NVIDIA GPU passthrough for Ollama (requires NVIDIA Container Toolkit)
2729
2830
General Options:
2931
--help, -h Show this help message
@@ -32,12 +34,15 @@ General Options:
3234
Examples:
3335
pgpm docker start Start PostgreSQL only
3436
pgpm docker start --minio Start PostgreSQL + MinIO
37+
pgpm docker start --ollama Start PostgreSQL + Ollama (CPU)
38+
pgpm docker start --ollama --gpu Start PostgreSQL + Ollama (NVIDIA GPU)
3539
pgpm docker start --port 5433 Start on custom port
3640
pgpm docker start --shm-size 4g Start with 4GB shared memory
3741
pgpm docker start --recreate Remove and recreate containers
3842
pgpm docker start --recreate --minio Recreate PostgreSQL + MinIO
3943
pgpm docker stop Stop PostgreSQL
4044
pgpm docker stop --minio Stop PostgreSQL + MinIO
45+
pgpm docker stop --ollama Stop PostgreSQL + Ollama
4146
pgpm docker ls List services and status
4247
`;
4348

@@ -68,6 +73,7 @@ interface ServiceDefinition {
6873
env: Record<string, string>;
6974
command?: string[];
7075
volumes?: VolumeMapping[];
76+
gpuCapable?: boolean;
7177
}
7278

7379
const ADDITIONAL_SERVICES: Record<string, ServiceDefinition> = {
@@ -85,6 +91,16 @@ const ADDITIONAL_SERVICES: Record<string, ServiceDefinition> = {
8591
command: ['server', '/data', '--console-address', ':9001'],
8692
volumes: [{ name: 'minio-data', containerPath: '/data' }],
8793
},
94+
ollama: {
95+
name: 'ollama',
96+
image: 'ollama/ollama',
97+
ports: [
98+
{ host: 11434, container: 11434 },
99+
],
100+
env: {},
101+
volumes: [{ name: 'ollama-data', containerPath: '/root/.ollama' }],
102+
gpuCapable: true,
103+
},
88104
};
89105

90106
interface SpawnResult {
@@ -243,7 +259,7 @@ async function stopContainer(name: string): Promise<void> {
243259
}
244260
}
245261

246-
async function startService(service: ServiceDefinition, recreate: boolean): Promise<void> {
262+
async function startService(service: ServiceDefinition, recreate: boolean, gpu: boolean = false): Promise<void> {
247263
const { name, image, ports, env: serviceEnv, command } = service;
248264

249265
const exists = await containerExists(name);
@@ -295,6 +311,10 @@ async function startService(service: ServiceDefinition, recreate: boolean): Prom
295311
}
296312
}
297313

314+
if (gpu && service.gpuCapable) {
315+
runArgs.push('--gpus', 'all');
316+
}
317+
298318
runArgs.push(image);
299319

300320
if (command) {
@@ -382,13 +402,14 @@ export default async (
382402
const password = (args.password as string) || 'password';
383403
const shmSize = (args['shm-size'] as string) || (args.shmSize as string) || '2g';
384404
const recreate = args.recreate === true;
405+
const gpu = args.gpu === true;
385406
const includedServices = resolveServiceFlags(args);
386407

387408
switch (subcommand) {
388409
case 'start':
389410
await startContainer({ name, image, port, user, password, shmSize, recreate });
390411
for (const service of includedServices) {
391-
await startService(service, recreate);
412+
await startService(service, recreate, gpu);
392413
}
393414
break;
394415

0 commit comments

Comments
 (0)