Skip to content

feat: forward brick container ports#296

Open
lucarin91 wants to merge 6 commits intoarduino:mainfrom
lucarin91:forward-brick-container-ports
Open

feat: forward brick container ports#296
lucarin91 wants to merge 6 commits intoarduino:mainfrom
lucarin91:forward-brick-container-ports

Conversation

@lucarin91
Copy link
Copy Markdown
Contributor

@lucarin91 lucarin91 commented Mar 13, 2026

Motivation

Change description

  1. Extract brick compose exposed ports and return them to app-lab
  2. Remove the webview hardcoded tag on app.yaml ports

Additional Notes

Reviewer checklist

  • PR addresses a single concern.
  • PR title and description are properly filled.
  • Changes will be merged in main.
  • Changes are covered by tests.
  • Logging is meaningful in case of troubleshooting.

@lucarin91 lucarin91 requested review from a team and dido18 March 13, 2026 15:21
@lucarin91 lucarin91 linked an issue Mar 13, 2026 that may be closed by this pull request
@per1234 per1234 added the enhancement New feature or request label Mar 13, 2026
@lucarin91 lucarin91 linked an issue Mar 16, 2026 that may be closed by this pull request
3 tasks
@lucarin91 lucarin91 marked this pull request as ready for review March 16, 2026 10:55
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 18, 2026

CLA assistant check
All committers have signed the CLA.

Comment on lines +75 to +76
Port: strconv.Itoa(p),
Source: "app.yaml",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am ok to remove the webview from the app.yaml definition.
Having this change, it is not possible to define a port in the app.yaml with webview behaviour.
It is only possible to set it from the brick definition.

Copy link
Copy Markdown
Contributor

@Xayton Xayton Mar 31, 2026

Choose a reason for hiding this comment

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

I agree. I think we have a bigger problem here.

  1. The requires_display in the brick_config.yaml is at the root level. If you have multiple ports, it's not clear which one should be opened.
  2. There is not way to specify the same concept "requires display" in the ports of the app.yaml file.

It would be nice to have the "port type" (which includes the concept of "requires display") for each port, and make it work the same both in brick_config.yaml and app.yaml.

Something like (see comments):

id: arduino:web_ui
name: WebUI - HTML
category: ui

# requires_display: webview # REMOVED, NOT SUPPORTED

ports:
  - 7000: webview # port should be opened in a browser when the app is launched (and thus forwarded by App Lab)
  - 8000: internal # port should not be opened or forwarded. used for brick-to-brick communication
  - 9000 # no type: port will be forwarded by App Lab, but not opened in a browser

Comment on lines +140 to +147
if strings.Contains(portStr, ":") {
parts := strings.Split(portStr, ":")
hostPort := parts[len(parts)-2] // Extract the host port (the one before the last colon)
index.Bricks[i].containerPorts = append(index.Bricks[i].containerPorts, hostPort)
} else {
index.Bricks[i].containerPorts = append(index.Bricks[i].containerPorts, portStr)
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would add a unit test for the port parsing
Currenlty we have this ${BIND_ADDRESS:-127.0.0.1}:1340:1337

if err != nil {
return nil, err
}
defer f.Close()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

having a defer f.Close() inside the loop causes many pending f.Close() at the same time, since the defer will be called at the end of Load().
We could extract a helper function to get the ports: getComposePorts(composeFilePath *paths.Path) ([]string, error)

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.

Forward brick ports to app-lab Hardcoded webview in the ports

6 participants