Skip to content

Commit 46961a2

Browse files
committed
feat(pgpm): add named volume support for additional services
- Add VolumeMapping interface and volumes field to ServiceDefinition - Minio now uses a named 'minio-data' volume for persistent /data storage - Data persists across stop/start and --recreate cycles
1 parent 693c26a commit 46961a2

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

pgpm/cli/src/commands/docker.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,18 @@ interface PortMapping {
5858
container: number;
5959
}
6060

61+
interface VolumeMapping {
62+
name: string;
63+
containerPath: string;
64+
}
65+
6166
interface ServiceDefinition {
6267
name: string;
6368
image: string;
6469
ports: PortMapping[];
6570
env: Record<string, string>;
6671
command?: string[];
72+
volumes?: VolumeMapping[];
6773
}
6874

6975
const ADDITIONAL_SERVICES: Record<string, ServiceDefinition> = {
@@ -76,6 +82,7 @@ const ADDITIONAL_SERVICES: Record<string, ServiceDefinition> = {
7682
MINIO_SECRET_KEY: 'minioadmin',
7783
},
7884
command: ['server', '/data'],
85+
volumes: [{ name: 'minio-data', containerPath: '/data' }],
7986
},
8087
};
8188

@@ -281,6 +288,12 @@ async function startService(service: ServiceDefinition, recreate: boolean): Prom
281288
runArgs.push('-p', `${portMapping.host}:${portMapping.container}`);
282289
}
283290

291+
if (service.volumes) {
292+
for (const vol of service.volumes) {
293+
runArgs.push('-v', `${vol.name}:${vol.containerPath}`);
294+
}
295+
}
296+
284297
runArgs.push(image);
285298

286299
if (command) {

0 commit comments

Comments
 (0)