Add proper support for relative WORKDIR instructions

Fixes #3937