Skip to content

Commit 1244735

Browse files
author
Dave Wichers
committed
Fix runBearer.sh script so docker now works in the tighter/more constrained
permissions environment on Linux.
1 parent 2565f29 commit 1244735

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

scripts/runBearer.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
# Check for install/updates at https://github.com/bearer/bearer
44

5+
# For this script to work, you need to change the permissions on the results/ directory to 777
6+
# so docker can write the results file into the results/ folder
7+
58
source scripts/requireCommand.sh
69

710
requireCommand docker
@@ -10,6 +13,17 @@ docker pull bearer/bearer --platform linux/amd64
1013

1114
benchmark_version=$(scripts/getBenchmarkVersion.sh)
1215
bearer_version=$(docker run --platform linux/amd64 bearer/bearer bearer --version | grep -o '[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+')
13-
result_file="/src/results/Benchmark_$benchmark_version-Bearer-v$bearer_version.json"
16+
result_file="results/Benchmark_$benchmark_version-Bearer-v$bearer_version.json"
17+
temp_result_file="$result_file.tmp"
18+
docker_result_file="/benchmark/$temp_result_file"
19+
20+
# if you set the Docker userid to match the current user id with: --user $(id -u):$(id -g) you get a suspicious git repository error
21+
docker run --platform linux/amd64 --rm -v "${PWD}:/benchmark" bearer/bearer scan /benchmark/src/main/ --format jsonv2 --output "$docker_result_file" > /dev/null
22+
23+
# Because the docker userid and current user ID might be different, we write the Bearer result to a temp file.
24+
# Then copy it to the desired file name, and then delete the temp file.
25+
#
26+
# We can't just chown the file to the right user ID as Unix won't allow that.
27+
cp $temp_result_file $result_file
28+
rm -f $temp_result_file
1429

15-
docker run --platform linux/amd64 --rm -v "${PWD}:/src" bearer/bearer scan /src/src/main/ --format jsonv2 --output "$result_file" > /dev/null

0 commit comments

Comments
 (0)