Skip to content

ci: trust all Git directories for non-root CI/CD execution - #117

Merged
appleboy merged 2 commits into
masterfrom
docker
Dec 30, 2025
Merged

ci: trust all Git directories for non-root CI/CD execution#117
appleboy merged 2 commits into
masterfrom
docker

Conversation

@appleboy

@appleboy appleboy commented Dec 29, 2025

Copy link
Copy Markdown
Owner
  • Configure Git to trust all directories to prevent errors when running as a non-root user in CI/CD environments

fix #112
fix #111

- Configure Git to trust all directories to prevent errors when running as a non-root user in CI/CD environments

fix #112 #111

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Copilot AI review requested due to automatic review settings December 29, 2025 11:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR configures Git to trust all directories in the Docker container to resolve "fatal: not in a git directory" errors that occur when running as a non-root user in CI/CD environments. This addresses issues #112 and #111.

  • Adds Git system-level configuration to trust all directories using the wildcard pattern
  • Places the configuration command before the USER switch to ensure proper permissions
  • Includes explanatory comments about the purpose and necessity in CI/CD contexts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docker/Dockerfile Outdated
Comment on lines +20 to +22
# Configure Git to trust all directories to avoid "fatal: not in a git directory" errors
# This is necessary when running as non-root user in CI/CD environments
RUN git config --system --add safe.directory '*'

Copilot AI Dec 29, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting safe.directory '*' in the system Git config disables Git’s ownership safety checks (introduced for CVE-2022-24765), effectively trusting every Git working directory on the filesystem. If this image is ever used in a shared or multi-tenant environment, an attacker who can place a malicious Git repository owned by another user could trigger Git commands that honor that repository’s config and hooks, leading to arbitrary command execution or credential exfiltration under the appuser (or container) privileges. To reduce this risk, avoid the wildcard and restrict safe.directory to the specific workspace path(s) used in CI, or adjust the filesystem/UID setup so that Git does not see an ownership mismatch instead of globally trusting all directories.

Suggested change
# Configure Git to trust all directories to avoid "fatal: not in a git directory" errors
# This is necessary when running as non-root user in CI/CD environments
RUN git config --system --add safe.directory '*'
# Configure Git to trust the Drone workspace directory to avoid ownership errors
# when running as non-root user in CI/CD environments, without trusting all paths
RUN git config --system --add safe.directory /drone/src

Copilot uses AI. Check for mistakes.
- Combine package installation, user creation, and Git configuration into a single RUN instruction to streamline Docker build steps

Signed-off-by: appleboy <appleboy.tw@gmail.com>
@appleboy
appleboy merged commit 13ddff5 into master Dec 30, 2025
9 checks passed
@appleboy
appleboy deleted the docker branch December 30, 2025 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fatal: not in a git directory CI is failing with latest update

2 participants