Skip to content

Commit

Permalink
fix: change Git config inside Docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
abrown committed Mar 8, 2024
1 parent 59e5556 commit 72dfc78
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ package: build/package.BUILT

build/package.BUILT: build strip
mkdir -p dist
./docker_ensure_git_access.sh
./deb_from_installation.sh $(shell pwd)/dist "$(VERSION)" "$(BUILD_PREFIX)"
./tar_from_installation.sh "$(shell pwd)/dist" "$(VERSION)" "$(BUILD_PREFIX)"
touch build/package.BUILT
Expand Down
5 changes: 0 additions & 5 deletions docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ set -ex
echo "Building the docker image"
docker build -t wasi-sdk-builder:latest .

if ! git config safe.directory | grep --quiet /workspace; then
echo "Setting up Git safe directory"
git config --global --add safe.directory /workspace
fi

echo "Building the package in docker image"
mkdir -p ~/.ccache
docker run --rm -v "$PWD":/workspace -v ~/.ccache:/root/.ccache -e NINJA_FLAGS=-v --workdir /workspace --tmpfs /tmp:exec wasi-sdk-builder:latest make package LLVM_CMAKE_FLAGS=-DLLVM_CCACHE_BUILD=ON
18 changes: 18 additions & 0 deletions docker_ensure_git_access.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# When running any git command inside a Docker container the user is different
# than usual so Git thinks something fishy is going on. Git will print something
# like:
#
# > fatal: detected dubious ownership in repository at '/workspace'
# > To add an exception for this directory, call:
# >
# > git config --global --add safe.directory /workspace
#
# This script runs that command to avoid this error.

set -ex
if ! git config safe.directory | grep --quiet /workspace; then
echo "Setting up Git safe directory"
git config --global --add safe.directory /workspace
fi

0 comments on commit 72dfc78

Please sign in to comment.