Skip to content

Conversation

crazy-max
Copy link
Member

@crazy-max crazy-max commented May 25, 2023

record-2023-05-31.141327.mp4

Display build details links if Docker Desktop build backend is enabled.

I'm using an OSC 8 escape sequence with the target links to be displayed in the terminal. Most of the terminal emulators auto-detect when a URL appears onscreen and allow to conveniently open them (e.g. via Ctrl+click or Cmd+click, or the right click menu). A hyperlink is opened upon encountering an OSC 8 escape sequence with the link. The list of supporting terminal emulators and terminal-based apps can be seen here: https://github.com/Alhadis/OSC8-Adoption/.

Atm it only displays links when build is completed and not for active builds. For active builds we need to put links right before build starts so user can just follow build status in desktop instead of his terminal. Would also need a callback to retrieve the ref when attributes are converted to solve opts.

build/build.go Outdated
Node: node.Name,
Ref: so.Ref,
}
}
if resultHandleFunc != nil {
resultCtx, err := NewResultContext(ctx, cc, so, res)
Copy link
Member Author

Choose a reason for hiding this comment

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

@jedevc If we want to print in commands pkg I was wondering if we could use the result context handler to set the build details opts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ResultContext doesn't leave outside the controller boundary, so that would likely only work for the runBasicBuild case I think 😢 Although, we do record the build options, so controller.Inspect could work for this?

Though that's only the controller options, not the full solve request.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah right thanks for the feedback, I will take a closer look.

Copy link
Member Author

Choose a reason for hiding this comment

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

Builder name, node name when driver pairs are computed during build are not inputs so doesn't look good to have it in build options. Same for the refID computed for each solve opt.

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened #1861 to carry changes from #1680. Will revisit changes here once switching bake to controller for building.

@crazy-max crazy-max force-pushed the desktop branch 2 times, most recently from 73486dd to f6c0278 Compare May 30, 2023 18:39
@tonistiigi
Copy link
Member

@crazy-max Looks like multiple CI issues.

@tonistiigi
Copy link
Member

These comments have not been resolved:

I think it is better if this logging is in cmd packages.

If you print escape sequences then you also need to detect that you are actually writing to a terminal, not to a file etc. (see full previous comment for alternatives)

We should only print if Build() ran and either was successful or we got error from BuildKit. Otherwise BuildKit has not registered the ref yet and it is useless.

The link is not shown at all on error anymore iiuc.

I'm not sure if we should show the link with --print. If not then these builds should be marked as internal so they don't get registered by history API.

@crazy-max crazy-max changed the title build: display docker desktop build details link build: display build details link May 31, 2023
@crazy-max crazy-max force-pushed the desktop branch 3 times, most recently from 7a39d38 to a59d72f Compare May 31, 2023 11:56
@crazy-max
Copy link
Member Author

crazy-max commented May 31, 2023

I think it is better if this logging is in cmd packages.

Moved to commands package

If you print escape sequences then you also need to detect that you are actually writing to a terminal, not to a file etc. (see full previous comment for alternatives)

Added detection using containerd/console.

We should only print if Build() ran and either was successful or we got error from BuildKit. Otherwise BuildKit has not registered the ref yet and it is useless.

It now prints on error as well. I was looking at using ResultContext and it works fine with build command but we don't have any implementation yet for bake so in the meantime I return an extra arg that contains the build details.

@crazy-max crazy-max force-pushed the desktop branch 2 times, most recently from 375b537 to 91677bf Compare June 2, 2023 11:12
@crazy-max crazy-max requested a review from tonistiigi June 2, 2023 11:16
@crazy-max crazy-max marked this pull request as ready for review June 2, 2023 11:16
@crazy-max crazy-max force-pushed the desktop branch 3 times, most recently from f896fed to e41911f Compare June 6, 2023 08:53
@crazy-max crazy-max requested a review from tonistiigi June 6, 2023 08:54
We are using the quiet flag option and we are not taking
progress quiet mode into account

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
@crazy-max crazy-max merged commit 99e3882 into docker:master Jun 6, 2023
@crazy-max crazy-max deleted the desktop branch June 6, 2023 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants