remote build: EvalSymlinks() the context directory

Use EvalSymlinks() to find the context directory, in case there's
shenanigans.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai
2021-09-27 09:23:04 -04:00
parent 800d594afa
commit 464fec260c
2 changed files with 12 additions and 0 deletions

View File

@ -230,6 +230,9 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
params.Add("platform", platform)
}
}
if contextDir, err := filepath.EvalSymlinks(options.ContextDirectory); err == nil {
options.ContextDirectory = contextDir
}
params.Set("pullpolicy", options.PullPolicy.String())

View File

@ -956,6 +956,15 @@ EOF
run_podman build -t build_test $tmpdir
}
@test "podman build build context is a symlink to a directory" {
tmpdir=$PODMAN_TMPDIR/build-test
mkdir -p $tmpdir/target
ln -s target $tmpdir/link
echo FROM alpine > $tmpdir/link/Dockerfile
echo RUN echo hello >> $tmpdir/link/Dockerfile
run_podman build -t build_test $tmpdir/link
}
function teardown() {
# A timeout or other error in 'build' can leave behind stale images
# that podman can't even see and which will cascade into subsequent