Skip to content

Conversation

@antirotor
Copy link
Member

Changelog Description

Pass ports definition to spawned service.

Additional review information

Portsd were not passed to the service. It can be now defined using ynput/ayon-frontend#1328

Closes #14

Testing notes:

  • Define service with ports (like [4000:4000])
  • Let ash to create and run it

@antirotor antirotor requested a review from Copilot July 15, 2025 16:09
@antirotor antirotor self-assigned this Jul 15, 2025
@antirotor antirotor added the enhancement New feature or request label Jul 15, 2025

This comment was marked as outdated.

@antirotor antirotor requested review from Copilot and martastain July 16, 2025 13:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds port mapping functionality to the service spawning system, allowing services to define and use port configurations when creating Docker containers. The change enables services to specify port mappings in the format [4000:4000] which are then passed to the Docker container creation process.

  • Adds ports parameter to the spawn method signature with proper type annotation
  • Implements port parsing logic to handle both single port and host:container port mapping formats
  • Integrates port configuration into the container creation workflow when network mode is not "host"

thanks copilot for the wrong suggestion
volumes.append(bind_mount)

ports: dict[str, int | None] = {}
if config.network_mode != "host":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to docker python docs:

None, to assign a random host port. For example, {'2222/tcp': None}.

This is probably not what would user intended. Also the dict passed to run is "inverted" - not the same structure as in docker cli or docker compose:

While in docker compose, you specify HOST_PORT: CONTAINER_PORT, here, the dict is {CONTAINER_PORT: HOST_PORT} This is because host port in this api could be a tuple and you can use multiple host ports for the single container port.

i would expect, that if i add a single line containing 8080 , it would map host port 8080 to container port 8080 (equivalent to - 8080:8080 in docker compose, or {8080: 8080} in the python api.

And IMO docker-compose structure is probably more familiar to the users so, i'd keep the host:container ordering in the ui syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Service not exposing ports

3 participants