Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 12 additions & 26 deletions pgpm/cli/src/commands/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ Docker Command:
pgpm docker <subcommand> [OPTIONS]

Manage Docker containers for local development.
PostgreSQL is always started by default. Additional services can be
included with the --include flag.
PostgreSQL is always started by default.

Subcommands:
start Start containers
Expand All @@ -23,23 +22,22 @@ PostgreSQL Options:
--password <pass> PostgreSQL password (default: password)
--shm-size <size> Shared memory size for container (default: 2g)

Additional Services:
--minio Include MinIO S3-compatible object storage (port 9000)

General Options:
--help, -h Show this help message
--recreate Remove and recreate containers on start
--include <svc> Include additional service (can be repeated)

Available Additional Services:
minio MinIO S3-compatible object storage (port 9000)

Examples:
pgpm docker start Start PostgreSQL only
pgpm docker start --include minio Start PostgreSQL + MinIO
pgpm docker start --minio Start PostgreSQL + MinIO
pgpm docker start --port 5433 Start on custom port
pgpm docker start --shm-size 4g Start with 4GB shared memory
pgpm docker start --recreate Remove and recreate containers
pgpm docker start --recreate --include minio Recreate PostgreSQL + MinIO
pgpm docker start --recreate --minio Recreate PostgreSQL + MinIO
pgpm docker stop Stop PostgreSQL
pgpm docker stop --include minio Stop PostgreSQL + MinIO
pgpm docker stop --minio Stop PostgreSQL + MinIO
pgpm docker ls List services and status
`;

Expand Down Expand Up @@ -315,21 +313,10 @@ async function stopService(service: ServiceDefinition): Promise<void> {
await stopContainer(service.name);
}

function parseInclude(args: Partial<Record<string, any>>): string[] {
const include = args.include;
if (!include) return [];
if (Array.isArray(include)) return include as string[];
if (typeof include === 'string') return [include];
return [];
}

function resolveIncludedServices(includeNames: string[]): ServiceDefinition[] {
function resolveServiceFlags(args: Partial<Record<string, any>>): ServiceDefinition[] {
const services: ServiceDefinition[] = [];
for (const name of includeNames) {
const service = ADDITIONAL_SERVICES[name];
if (!service) {
console.warn(`⚠️ Unknown service: "${name}". Available: ${Object.keys(ADDITIONAL_SERVICES).join(', ')}`);
} else {
for (const [key, service] of Object.entries(ADDITIONAL_SERVICES)) {
if (args[key] === true || typeof args[key] === 'string') {
services.push(service);
}
}
Expand All @@ -350,7 +337,7 @@ async function listServices(): Promise<void> {
console.log(' postgres constructiveio/postgres-plus:18 \x1b[90m(docker not available)\x1b[0m');
}

console.log('\n Additional (use --include <name>):');
console.log('\n Additional (use --<name> flag):');

for (const [key, service] of Object.entries(ADDITIONAL_SERVICES)) {
if (dockerAvailable) {
Expand Down Expand Up @@ -392,8 +379,7 @@ export default async (
const password = (args.password as string) || 'password';
const shmSize = (args['shm-size'] as string) || (args.shmSize as string) || '2g';
const recreate = args.recreate === true;
const includeNames = parseInclude(args);
const includedServices = resolveIncludedServices(includeNames);
const includedServices = resolveServiceFlags(args);

switch (subcommand) {
case 'start':
Expand Down
2 changes: 1 addition & 1 deletion pgpm/cli/src/utils/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const usageText = `
deps Show change dependencies

Development Tools:
docker Manage Docker containers (start/stop/ls, --include for additional services)
docker Manage Docker containers (start/stop/ls, --minio)
env Manage environment variables (--supabase, --minio)
test-packages Run integration tests on workspace packages

Expand Down
Loading