161ef94b4f
Check engine pin consistency / Dockerfile / CI pin consistency (push) Successful in 8s
Sirius CI/CD Pipeline / Detect Changes (push) Successful in 23s
Validate Docker Configuration / Validate Docker Compose Configuration (push) Successful in 47s
Sirius CI/CD Pipeline / Build API (${{ matrix.platform }}) (push) Has been cancelled
Sirius CI/CD Pipeline / Build UI (${{ matrix.platform }}) (push) Has been cancelled
Sirius CI/CD Pipeline / Merge Engine Manifest (push) Has been cancelled
Sirius CI/CD Pipeline / Merge API Manifest (push) Has been cancelled
Sirius CI/CD Pipeline / Merge UI Manifest (push) Has been cancelled
Sirius CI/CD Pipeline / Build Engine (${{ matrix.platform }}) (push) Has been cancelled
Sirius CI/CD Pipeline / Build Infra (${{ matrix.service }}, ${{ matrix.platform }}) (push) Has been cancelled
Sirius CI/CD Pipeline / Merge Infra Manifest (sirius-postgres) (push) Has been cancelled
Sirius CI/CD Pipeline / Merge Infra Manifest (sirius-rabbitmq) (push) Has been cancelled
Sirius CI/CD Pipeline / Merge Infra Manifest (sirius-valkey) (push) Has been cancelled
Sirius CI/CD Pipeline / Integration Test (push) Has been cancelled
Sirius CI/CD Pipeline / Public Stack Contract (push) Has been cancelled
Sirius CI/CD Pipeline / Dispatch Demo Deployment (sirius-demo branch) (push) Has been cancelled
Sirius CI/CD Pipeline / Dispatch Demo Canary (main branch) (push) Has been cancelled
Sirius CI/CD Pipeline / Guard Registry Namespace (push) Has been cancelled
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { parseYamlFile } from '../utils/yaml-parser.js';
|
|
|
|
interface DockerComposeService {
|
|
ports?: string[];
|
|
[key: string]: any;
|
|
}
|
|
|
|
interface DockerCompose {
|
|
services: Record<string, DockerComposeService>;
|
|
}
|
|
|
|
export async function extractPorts(
|
|
dockerComposePath: string,
|
|
serviceName: string,
|
|
portsConfig: Record<string, string> = {}
|
|
): Promise<string> {
|
|
try {
|
|
const compose = await parseYamlFile(dockerComposePath) as DockerCompose;
|
|
|
|
if (!compose.services || !compose.services[serviceName]) {
|
|
return `Service "${serviceName}" not found in docker-compose.yaml`;
|
|
}
|
|
|
|
const service = compose.services[serviceName];
|
|
|
|
if (!service.ports || service.ports.length === 0) {
|
|
return 'No ports configured for this service';
|
|
}
|
|
|
|
// Format ports section
|
|
let result = '**Server Ports:**\n\n';
|
|
|
|
for (const portMapping of service.ports) {
|
|
// Parse port mapping (e.g., "50051:50051" or "8080:80")
|
|
const match = portMapping.match(/(\d+):(\d+)/);
|
|
if (match) {
|
|
const [, hostPort, containerPort] = match;
|
|
const description = portsConfig[hostPort] || portsConfig[containerPort] || '';
|
|
result += `- \`${hostPort}\` - ${description || `Maps to container port ${containerPort}`}\n`;
|
|
}
|
|
}
|
|
|
|
return result.trim();
|
|
} catch (error) {
|
|
return `Error extracting ports: ${error}`;
|
|
}
|
|
}
|
|
|
|
|