Merge pull request #277 from tonistiigi/copy-fix
dockerfile: fix issues with duplicate copy instructionsdocker-18.09
commit
da21a0d1ee
|
@ -378,7 +378,7 @@ func dispatchWorkdir(d *dispatchState, c *instructions.WorkdirCommand, commit bo
|
|||
|
||||
func dispatchCopy(d *dispatchState, c instructions.SourcesAndDest, sourceState llb.State, isAddCommand bool, cmdToPrint interface{}, chown string) error {
|
||||
// TODO: this should use CopyOp instead. Current implementation is inefficient
|
||||
img := llb.Image("tonistiigi/copy@sha256:9e6b90a83acc95831c81a0c9c6e45e27b439c19e7974f34f258971e454c8b793")
|
||||
img := llb.Image("tonistiigi/copy@sha256:476e0a67a1e4650c6adaf213269a2913deb7c52cbc77f954026f769d51e1a14e")
|
||||
|
||||
dest := path.Join("/dest", pathRelativeToWorkingDir(d.state, c.Dest()))
|
||||
if c.Dest() == "." || c.Dest()[len(c.Dest())-1] == filepath.Separator {
|
||||
|
|
|
@ -47,6 +47,7 @@ func TestIntegration(t *testing.T) {
|
|||
testDockerfileFromGit,
|
||||
testCopyChown,
|
||||
testCopyWildcards,
|
||||
testCopyOverrideFiles,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -804,6 +805,60 @@ COPY --from=base /out /
|
|||
require.Equal(t, string(dt), "1000 nogroup\n")
|
||||
}
|
||||
|
||||
func testCopyOverrideFiles(t *testing.T, sb integration.Sandbox) {
|
||||
t.Parallel()
|
||||
|
||||
dockerfile := []byte(`
|
||||
FROM scratch AS base
|
||||
COPY sub sub
|
||||
COPY sub sub
|
||||
COPY files/foo.go dest/foo.go
|
||||
COPY files/foo.go dest/foo.go
|
||||
COPY files dest
|
||||
`)
|
||||
|
||||
dir, err := tmpdir(
|
||||
fstest.CreateFile("Dockerfile", dockerfile, 0600),
|
||||
fstest.CreateDir("sub", 0700),
|
||||
fstest.CreateDir("sub/dir1", 0700),
|
||||
fstest.CreateDir("sub/dir1/dir2", 0700),
|
||||
fstest.CreateFile("sub/dir1/dir2/foo", []byte(`foo-contents`), 0600),
|
||||
fstest.CreateDir("files", 0700),
|
||||
fstest.CreateFile("files/foo.go", []byte(`foo.go-contents`), 0600),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
c, err := client.New(sb.Address())
|
||||
require.NoError(t, err)
|
||||
defer c.Close()
|
||||
|
||||
destDir, err := ioutil.TempDir("", "buildkit")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(destDir)
|
||||
|
||||
err = c.Solve(context.TODO(), nil, client.SolveOpt{
|
||||
Frontend: "dockerfile.v0",
|
||||
Exporter: client.ExporterLocal,
|
||||
ExporterAttrs: map[string]string{
|
||||
"output": destDir,
|
||||
},
|
||||
LocalDirs: map[string]string{
|
||||
builder.LocalNameDockerfile: dir,
|
||||
builder.LocalNameContext: dir,
|
||||
},
|
||||
}, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
dt, err := ioutil.ReadFile(filepath.Join(destDir, "sub/dir1/dir2/foo"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, string(dt), "foo-contents")
|
||||
|
||||
dt, err = ioutil.ReadFile(filepath.Join(destDir, "dest/foo.go"))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, string(dt), "foo.go-contents")
|
||||
}
|
||||
|
||||
func testCopyWildcards(t *testing.T, sb integration.Sandbox) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
Loading…
Reference in New Issue