add test for workdir env vars and add docs

This PR carries #7033 to master. The actual code changes to the builder aren't relevant any more, but the test and the documentation change are still relevant.