Merge pull request #733 from tonistiigi/dockerfile-symlink

dockerfile: allow symlinks on reading Dockerfile
docker-18.09
Akihiro Suda 2018-11-21 12:32:08 +09:00 committed by GitHub
commit e59b01bf82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View File

@ -99,7 +99,7 @@ func Build(ctx context.Context, c client.Client) (*client.Result, error) {
name := "load build definition from " + filename
src := llb.Local(LocalNameDockerfile,
llb.IncludePatterns([]string{filename}),
llb.FollowPaths([]string{filename}),
llb.SessionID(c.BuildOpts().SessionID),
llb.SharedKeyHint(defaultDockerfileName),
dockerfile2llb.WithInternalName(name),
@ -189,7 +189,7 @@ func Build(ctx context.Context, c client.Client) (*client.Result, error) {
if dockerignoreState == nil {
st := llb.Local(LocalNameContext,
llb.SessionID(c.BuildOpts().SessionID),
llb.IncludePatterns([]string{dockerignoreFilename}),
llb.FollowPaths([]string{dockerignoreFilename}),
llb.SharedKeyHint(dockerignoreFilename),
dockerfile2llb.WithInternalName("load "+dockerignoreFilename),
)

View File

@ -80,6 +80,7 @@ var allTests = []integration.Test{
testCopyThroughSymlinkMultiStage,
testCopyChownCreateDest,
testEmptyDestDir,
testSymlinkedDockerfile,
}
var opts []integration.TestOpt
@ -151,6 +152,34 @@ RUN [ "$(cat testfile)" == "contents0" ]
require.NoError(t, err)
}
func testSymlinkedDockerfile(t *testing.T, sb integration.Sandbox) {
f := getFrontend(t, sb)
dockerfile := []byte(`
FROM scratch
ENV foo bar
`)
dir, err := tmpdir(
fstest.CreateFile("Dockerfile.web", dockerfile, 0600),
fstest.Symlink("Dockerfile.web", "Dockerfile"),
)
require.NoError(t, err)
defer os.RemoveAll(dir)
c, err := client.New(context.TODO(), sb.Address())
require.NoError(t, err)
defer c.Close()
_, err = f.Solve(context.TODO(), c, client.SolveOpt{
LocalDirs: map[string]string{
builder.LocalNameDockerfile: dir,
builder.LocalNameContext: dir,
},
}, nil)
require.NoError(t, err)
}
func testCopyChownCreateDest(t *testing.T, sb integration.Sandbox) {
f := getFrontend(t, sb)