Use RIOTPROJECT from within the riot repository if it is inside.
This means when it is the case to use:
* Not mounting the directory to `riotproject`
* Use `APPDIR` relative to inside RIOT
If it is not inside, do the same as before:
* Mount the RIOTPROJECT to `riotproject`
* Use `APPDIR` relative to RIOTPROJECT
Add functions to get volume and env arguments for a given directory environment
variable.
It handles:
* variables with multiple directories like EXTERNAL_MODULE_DIRS
* relative path
* if the 'directories' variable is empty, it will not be exported to docker
The 'build' directory should be created before starting docker.
If not it will be created as root.
Also add mapping for the directory in docker.
Currently create the directory in the target until there is a directory
creation target.
When building from a worktree, the common git directory was not mounted
in docker.
This lead to the version not being set and issues with git-cache in
ubuntu bionic that could not execute the 'git hash-object' command.
Not all users register their user in the docker group and should not run the
whole make process as root to use docker.
They can now overwrite DOCKER with `DOCKER="sudo docker"`.
Creating files as a user is correctly handled as `id -u` is still run as the
original user.