Fix git security issue with docker build
Make the docker user id and group id match the running user's, so that
files built by the container are seen as owned by the current user. Also
set the current directory as "safe" in git so it's able to inspect the
git history.
_note_: this will successfully run in a rootless docker install, but the
created files will have random uid/guids. You'll have to sudo to delete
them or chown them. For normal docker installs there should be no
issues. See [this issue](https://github.com/moby/moby/issues/41497) to
track the rootless problem on the docker side.