1
0
mirror of https://github.com/moby/moby.git synced 2025-07-29 07:21:35 +03:00

Implicit copy-from with reference

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2017-03-22 17:49:39 -07:00
parent 87512bbc84
commit 73b4b8ed7f
4 changed files with 147 additions and 73 deletions

View File

@ -5831,7 +5831,7 @@ func (s *DockerSuite) TestBuildCopyFromPreviousRootFSErrors(c *check.C) {
buildImage("build1", withExternalBuildContext(ctx)).Assert(c, icmd.Expected{
ExitCode: 1,
Err: "from expects an integer value corresponding to the context number",
Err: "invalid from flag value foo",
})
dockerfile = `
@ -5861,7 +5861,7 @@ func (s *DockerSuite) TestBuildCopyFromPreviousRootFSErrors(c *check.C) {
buildImage("build1", withExternalBuildContext(ctx)).Assert(c, icmd.Expected{
ExitCode: 1,
Err: "invalid context value bar",
Err: "invalid from flag value bar",
})
dockerfile = `
@ -5913,6 +5913,34 @@ func (s *DockerSuite) TestBuildCopyFromPreviousFrom(c *check.C) {
c.Assert(strings.TrimSpace(out), check.Equals, "def")
}
func (s *DockerSuite) TestBuildCopyFromImplicitFrom(c *check.C) {
dockerfile := `
FROM busybox
COPY --from=busybox /etc/passwd /mypasswd
RUN cmp /etc/passwd /mypasswd`
if DaemonIsWindows() {
dockerfile = `
FROM busybox
COPY --from=busybox License.txt foo`
}
ctx := fakeContext(c, dockerfile, map[string]string{
"Dockerfile": dockerfile,
})
defer ctx.Close()
result := buildImage("build1", withExternalBuildContext(ctx))
result.Assert(c, icmd.Success)
if DaemonIsWindows() {
out, _ := dockerCmd(c, "run", "build1", "cat", "License.txt")
c.Assert(len(out), checker.GreaterThan, 10)
out2, _ := dockerCmd(c, "run", "build1", "cat", "foo")
c.Assert(out, check.Equals, out2)
}
}
// TestBuildOpaqueDirectory tests that a build succeeds which
// creates opaque directories.
// See https://github.com/docker/docker/issues/25244