Merge pull request #33179 from tonistiigi/fix-from-scratch

Fix resetting image metadata between stages for scratch case
This commit is contained in:
Kenfe-Mickaël Laventure 2017-05-13 21:17:02 -07:00 коммит произвёл GitHub
Родитель 190c6e8cf8 b192218503
Коммит 4e0fdc9098
3 изменённых файлов: 24 добавлений и 1 удалений

Просмотреть файл

@ -8,6 +8,7 @@ package dockerfile
// package. // package.
import ( import (
"bytes"
"fmt" "fmt"
"regexp" "regexp"
"runtime" "runtime"
@ -16,7 +17,6 @@ import (
"strings" "strings"
"time" "time"
"bytes"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/api" "github.com/docker/docker/api"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"

Просмотреть файл

@ -219,6 +219,8 @@ func (s *dispatchState) beginStage(stageName string, image builder.Image) {
if image.RunConfig() != nil { if image.RunConfig() != nil {
s.runConfig = image.RunConfig() s.runConfig = image.RunConfig()
} else {
s.runConfig = &container.Config{}
} }
s.baseImage = image s.baseImage = image
s.setDefaultPath() s.setDefaultPath()

Просмотреть файл

@ -6202,6 +6202,27 @@ func (s *DockerSuite) TestBuildCopyFromWindowsIsCaseInsensitive(c *check.C) {
}) })
} }
// #33176
func (s *DockerSuite) TestBuildCopyFromResetScratch(c *check.C) {
testRequires(c, DaemonIsLinux)
dockerfile := `
FROM busybox
WORKDIR /foo/bar
FROM scratch
ENV FOO=bar
`
ctx := fakecontext.New(c, "",
fakecontext.WithDockerfile(dockerfile),
)
defer ctx.Close()
cli.BuildCmd(c, "build1", build.WithExternalBuildContext(ctx))
res := cli.InspectCmd(c, "build1", cli.Format(".Config.WorkingDir")).Combined()
c.Assert(strings.TrimSpace(res), checker.Equals, "")
}
func (s *DockerSuite) TestBuildIntermediateTarget(c *check.C) { func (s *DockerSuite) TestBuildIntermediateTarget(c *check.C) {
dockerfile := ` dockerfile := `
FROM busybox AS build-env FROM busybox AS build-env