Skip to content

enh: Smarter primary service detection in multi-service compose files #111

@nfebe

Description

@nfebe

Context

From PR #109 review.

pickPrimaryService returns the first service with ports/expose in multi-service compose files. In Go maps, iteration order is random, so the selected service may not be the intended primary.

Location

internal/docker/discovery.gopickPrimaryService()

Suggested improvement

Prioritize services named app or web before falling back to the first with ports:

for name, svc := range services {
    if (name == "app" || name == "web") && (len(svc.Ports) > 0 || len(svc.Expose) > 0) {
        return name, svc
    }
}
for name, svc := range services {
    if len(svc.Ports) > 0 || len(svc.Expose) > 0 {
        return name, svc
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions