-
Notifications
You must be signed in to change notification settings - Fork 575
Add --invoke
option to launch a container from the build result
#1168
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
Conversation
cc @tonistiigi |
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.
This looks like a great start 👍
Which sequence should be used to toggle IO? Currently C-a-c is used. Should it be configurable?
I think it is pretty good atm. We should consider also including ctrl-C
. Eg. when you are attached to container and press Ctrl-C
it could bring you to monitor mode. Pressing it again could give a warning about how to attach back, and another one close the program.
C-a-c atm doesn't show prompt. Need to press enter to get to the prompt.
Maybe for something common like reload we could add a special shortcut in the future.
Should container IO be accessible and readable even after it exits?
You mean stored in some file? I think we can think about that separately together with thinking if build logs need a similar feature.
Which driver and result should be used when multiple results are provided?
Native arch of the first node for selected driver seems like the best option.
For reload, currently it triggers the whole build again. This could be faster by just running a new solve with the same gateway connection (same Build()
callback). That would mean that, for example resolving a tag from registry for the base image is not needed between reloads. Or maybe we need two modes of reload.
Let's try to get this in quickly, mark the flags as experimental (maybe BUILDX_EXPERIMENTAL
env?), and then start to interate on it instead of trying to get the first PR to be the perfect experience.
build/build.go
Outdated
// Invoke invokes a build result as a container. | ||
func Invoke(ctx context.Context, cfg ContainerConfig) error { | ||
if cfg.ResultCtx == nil { | ||
return fmt.Errorf("result must be provided") |
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.
use pkg/errors
only in these repos.
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.
Thank you for the comment. fixed this.
build/build.go
Outdated
// ResultContext is a build result with the client that built it. | ||
type ResultContext struct { | ||
Client *client.Client | ||
SolveOpt client.SolveOpt |
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.
Do you even need SolveOpt
in here? The whole build is based on Res
. If SolveOpt
contains output options it may be even wrong to reuse it here.
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.
Thank you for the comment. fixed this.
4233661
to
6998921
Compare
Let's work on it in following-up patches. But it looks like it conflicts with the terminal keybind (for sending signals to the container)?
Fixed to show
Sure.
Current implementation uses the lowest index of the selected drivers. Does this look good?
Added this. |
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.
But it looks like it conflicts with the terminal keybind (for sending signals to the container)?
Yes, indeed it seems hard to predict if the signal was for cancelling the process or shell. Maybe if the process dies it goes to the buildx prompt first. We can think about this more later.
User need to explicitly send newline or something to get the prompt.
Could we just print enter for the user. I think we should either print enter or buffer the last line user saw and reprint it again. https://github.com/tonistiigi/vt100 could help if want to figure out what the last tty line is from a stream.
commands/build.go
Outdated
err = wrapBuildError(err, false) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if in.invoke != "" { | ||
if os.Getenv("BUILDX_EXPERIMENTAL") != "1" { |
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.
Better to just put the flag definition flags.StringVar(&options.invoke
behind env.
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
Fixed to automatically send a newline to the container on
Fixed this. |
#1104
This is a PoC of
--invoke
option to launch a container based on the build result.Please give me feedbacks on the design of the monitor and CLI design.
This covers PR1 to PR3 of #1104.
Example:
rollback
Ctrl-a-c
switches IO between monitor and container with printingSwitched IO
message.rollback
rollbacks the container by restarting it.reload
reload
reloads and builds the Dockerfile.exit
exit
exits the monitor.(buildx) exit
long form
Container is configurable through the long form of
--invoke
.TODOs
Remaining concerns
TODOs
Please tell me if I'm missing anything.