зеркало из https://github.com/microsoft/docker.git
builder: Emit a BuildResult after squashing.
This ensures that the final BuildResult is the actual tagged image. Fixes #33822. Signed-off-by: Ian Campbell <ian.campbell@docker.com>
This commit is contained in:
Родитель
d311a3a681
Коммит
9777ec3be0
|
@ -55,6 +55,11 @@ func (b *Backend) Build(ctx context.Context, config backend.BuildConfig) (string
|
|||
if imageID, err = squashBuild(build, b.imageComponent); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if config.ProgressWriter.AuxFormatter != nil {
|
||||
if err = config.ProgressWriter.AuxFormatter.Emit(types.BuildResult{ID: imageID}); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stdout := config.ProgressWriter.StdoutFormatter
|
||||
|
|
|
@ -6459,3 +6459,32 @@ func (s *DockerSuite) TestBuildIidFileCleanupOnFail(c *check.C) {
|
|||
c.Assert(err, check.NotNil)
|
||||
c.Assert(os.IsNotExist(err), check.Equals, true)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestBuildIidFileSquash(c *check.C) {
|
||||
testRequires(c, ExperimentalDaemon)
|
||||
tmpDir, err := ioutil.TempDir("", "TestBuildIidFileSquash")
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(tmpDir)
|
||||
tmpIidFile := filepath.Join(tmpDir, "iidsquash")
|
||||
|
||||
name := "testbuildiidfilesquash"
|
||||
// Use a Dockerfile with multiple stages to ensure we get the last one
|
||||
cli.BuildCmd(c, name,
|
||||
// This could be minimalBaseImage except
|
||||
// https://github.com/moby/moby/issues/33823 requires
|
||||
// `touch` to workaround.
|
||||
build.WithDockerfile(`FROM busybox
|
||||
ENV FOO FOO
|
||||
ENV BAR BAR
|
||||
RUN touch /foop
|
||||
`),
|
||||
cli.WithFlags("--iidfile", tmpIidFile, "--squash"))
|
||||
|
||||
id, err := ioutil.ReadFile(tmpIidFile)
|
||||
c.Assert(err, check.IsNil)
|
||||
d, err := digest.Parse(string(id))
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(d.String(), checker.Equals, getIDByName(c, name))
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче