Merge pull request #33824 from ijc/build-iidfile-with-squash
builder: Emit a BuildResult after squashing.
This commit is contained in:
commit
b8766fe793
2 changed files with 34 additions and 0 deletions
|
@ -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))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue