-
Notifications
You must be signed in to change notification settings - Fork 5
Add ports to service #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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
portsparameter to thespawnmethod 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": |
There was a problem hiding this comment.
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.
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:
[4000:4000])