dockerfile: allow symlinks on reading Dockerfile

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2018-11-20 18:13:15 -08:00
parent bf8c057e68
commit 2e3058e62c
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)