mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-19 01:47:43 +08:00
build: fix stdin handling when building with controller
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
parent
0a3e5e5257
commit
ffff87be03
@ -418,14 +418,22 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *contro
|
|||||||
var ref string
|
var ref string
|
||||||
var retErr error
|
var retErr error
|
||||||
var resp *client.SolveResponse
|
var resp *client.SolveResponse
|
||||||
f := ioset.NewSingleForwarder()
|
|
||||||
|
var f *ioset.SingleForwarder
|
||||||
|
var pr io.ReadCloser
|
||||||
|
var pw io.WriteCloser
|
||||||
|
if options.invokeConfig == nil {
|
||||||
|
pr = dockerCli.In()
|
||||||
|
} else {
|
||||||
|
f = ioset.NewSingleForwarder()
|
||||||
f.SetReader(dockerCli.In())
|
f.SetReader(dockerCli.In())
|
||||||
pr, pw := io.Pipe()
|
pr, pw = io.Pipe()
|
||||||
f.SetWriter(pw, func() io.WriteCloser {
|
f.SetWriter(pw, func() io.WriteCloser {
|
||||||
pw.Close() // propagate EOF
|
pw.Close() // propagate EOF
|
||||||
logrus.Debug("propagating stdin close")
|
logrus.Debug("propagating stdin close")
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
ref, resp, err = c.Build(ctx, *opts, pr, printer)
|
ref, resp, err = c.Build(ctx, *opts, pr, printer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -439,12 +447,14 @@ func runControllerBuild(ctx context.Context, dockerCli command.Cli, opts *contro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.invokeConfig != nil {
|
||||||
if err := pw.Close(); err != nil {
|
if err := pw.Close(); err != nil {
|
||||||
logrus.Debug("failed to close stdin pipe writer")
|
logrus.Debug("failed to close stdin pipe writer")
|
||||||
}
|
}
|
||||||
if err := pr.Close(); err != nil {
|
if err := pr.Close(); err != nil {
|
||||||
logrus.Debug("failed to close stdin pipe reader")
|
logrus.Debug("failed to close stdin pipe reader")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if options.invokeConfig != nil && options.invokeConfig.needsDebug(retErr) {
|
if options.invokeConfig != nil && options.invokeConfig.needsDebug(retErr) {
|
||||||
// Print errors before launching monitor
|
// Print errors before launching monitor
|
||||||
|
@ -69,11 +69,6 @@ func testBuild(t *testing.T, sb integration.Sandbox) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testBuildStdin(t *testing.T, sb integration.Sandbox) {
|
func testBuildStdin(t *testing.T, sb integration.Sandbox) {
|
||||||
if isExperimental() {
|
|
||||||
// FIXME: https://github.com/docker/buildx/issues/2368
|
|
||||||
t.Skip("build from stdin hangs in experimental mode: https://github.com/docker/buildx/issues/2368")
|
|
||||||
}
|
|
||||||
|
|
||||||
dockerfile := []byte(`
|
dockerfile := []byte(`
|
||||||
FROM busybox:latest AS base
|
FROM busybox:latest AS base
|
||||||
COPY foo /etc/foo
|
COPY foo /etc/foo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user