Proposal: specifying nested `DOCKERFILE_PATH` should change the build context
Apologies for being a bit late to the party on this one (seeing as gitlab-org/gitlab#212211 (closed) was already implemented).
After noticing support was added for DOCKERFILE_PATH
in auto-build-image:v3.x
I tried it out and it violated my expectations for how I'd expect this functionality to work:
Expected Behavior
Without looking at the build.sh
implementation details I would have assumed specifying a nested path within the repository would result in docker build $DOCKERFILE_PATH
. In other words I expected it to set the entire build context to the specified path.
Actual Behavior
What actually happens is we call docker build -f $DOCKERFILE_PATH .
which does not change the build context so all path references are still resolved from the root directory.
I would think most use cases for specifying a nested DOCKERFILE_PATH
involve repositories that assume each Dockerfile
is built with within the context of its relative path. This would provide more flexibility when building multiple images from a single repository.
Any use case that expects a file at /path/to/Dockerfile
to be built in the context of /
seems more contrived.