docker / buildx

Docker CLI plugin for extended build capabilities with BuildKit
Apache License 2.0
3.49k stars 471 forks source link

source snippet paths for warnings/errors should be relative to context/filename #2542

Closed tonistiigi closed 1 week ago

tonistiigi commented 3 months ago

Buildkit does not see the full path of Dockerfile is context is a subdir or a local path is passed with -f.

Command like

docker buildx build --check ./src/ld 

Gives me warnings

WARNING: WorkdirRelativePath - https://docs.docker.com/go/dockerfile/rule/workdir-relative-path/
Relative workdir "./apple-libtapi" can have unexpected results if the base image changes
Dockerfile:19
--------------------
  17 |     ARG LIBTAPI_VERSION
  18 |     RUN git clone https://github.com/tpoechtrager/apple-libtapi --depth 1 -b ${LIBTAPI_VERSION}
  19 | >>> WORKDIR ./apple-libtapi
  20 |     RUN --mount=target=/tmp/libtapi-cmake-args.patch,source=libtapi-cmake-args.patch \
  21 |         git apply /tmp/libtapi-cmake-args.patch
--------------------

Note the Dockerfile:19 while the actual path to the Dockerfile is ./src/ld/Dockerfile:19. In this case it is especially confusing as there is another Dockerfile in root directory as well. This also makes debugging harder as for example VSCode can detect these paths and can directly open a correct line, but atm it would open a line from wrong file for this case.