Merge branch 'feature/docker_git_safe_dirs_v5.2' into 'release/v5.2'

feat(docker): allow to add dirs into git's safe.directory (v5.2)

See merge request espressif/esp-idf!27557
This commit is contained in:
Roland Dobai 2023-12-01 19:04:54 +08:00
commit 60e439db60
3 changed files with 22 additions and 0 deletions

View File

@ -66,6 +66,10 @@ The above command explained:
- ``espressif/idf``: uses Docker image ``espressif/idf`` with tag ``latest``. The ``latest`` tag is implicitly added by Docker when no tag is specified.
- ``idf.py build``: runs this command inside the container.
.. note::
When the mounted directory, ``/project``, contains a git repository owned by a different user (``UID``) than the one running the Docker container, git commands executed within ``/project`` might fail, displaying an error message ``fatal: detected dubious ownership in repository at '/project'``. To resolve this issue, you can designate the ``/project`` directory as safe by setting the IDF_GIT_SAFE_DIR environment variable during the Docker container startup. For instance, you can achieve this by including ``-e IDF_GIT_SAFE_DIR='/project'`` as a parameter. Additionally, multiple directories can be specified by using a ``:`` separator. To entirely disable this git security check, ``*`` can be used.
To build with a specific Docker image tag, specify it as ``espressif/idf:TAG``, for example:
.. code-block:: bash

View File

@ -66,6 +66,10 @@ IDF Docker 镜像 (``espressif/idf``) 为使用特定版本的 ESP-IDF 自动化
- ``espressif/idf``:使用标签为 ``latest`` 的 Docker 镜像 ``espressif/idf``。未指定标签时Docker 会隐式添加 ``latest`` 标签。
- ``idf.py build``:在容器内运行此命令。
.. note::
如果挂载目录 ``/project`` 包含的 git 仓库的用户 (``UID``) 不同于运行 Docker 容器的用户,在 ``/project`` 中执行 git 命令可能会失败,并显示错误信息 ``fatal: detected dubious ownership in repository at '/project'``。如需解决此问题,可以在启动 Docker 容器时设置 IDF_GIT_SAFE_DIR 环境变量,将 ``/project`` 目录指定为安全目录。例如,可以将 ``-e IDF_GIT_SAFE_DIR='/project'`` 作为参数包含,还可以使用分隔符 ``:`` 指定多个目录,或使用 ``*`` 完全禁用此项 git 安全检查。
要以特定 Docker 镜像标签进行构建,请将其指定为 ``espressif/idf:TAG``,示例如下:
.. code-block:: bash

View File

@ -1,6 +1,20 @@
#!/usr/bin/env bash
set -e
# IDF_GIT_SAFE_DIR has the same format as system PATH environment variable.
# All path specified in IDF_GIT_SAFE_DIR will be added to user's
# global git config as safe.directory paths. For more information
# see git-config manual page.
if [ -n "${IDF_GIT_SAFE_DIR+x}" ]
then
echo "Adding following directories into git's safe.directory"
echo "$IDF_GIT_SAFE_DIR" | tr ':' '\n' | while read -r dir
do
git config --global --add safe.directory "$dir"
echo " $dir"
done
fi
. $IDF_PATH/export.sh
exec "$@"