File tree 3 files changed +13
-2
lines changed
3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,9 @@ COPY buildInDocker.sh $GOPATH
66
66
RUN chmod 777 $GOPATH/buildInDocker.sh
67
67
68
68
# Copy the rest of the source tree from this directory into the container
69
+ # And make sure it's readable by the id that will run the compiles (not just root)
69
70
COPY . $GOPATH/src/$ORG/$REPO
71
+ RUN chmod -R a+rx $GOPATH/src
70
72
71
73
# Set the entrypoint to the script that will do the compilation
72
74
ENTRYPOINT $GOPATH/buildInDocker.sh
Original file line number Diff line number Diff line change 20
20
export PATH=" ${PATH} :/usr/lib/go-${GOVERSION} /bin:/go/bin"
21
21
export CGO_CFLAGS=" -I/opt/mqm/inc/"
22
22
export CGO_LDFLAGS_ALLOW=" -Wl,-rpath.*"
23
+ export GOCACHE=/tmp/.gocache
24
+
25
+ echo " Running as " ` id`
23
26
24
27
# Build the libraries so they can be used by other programs
25
28
cd $GOPATH /src
Original file line number Diff line number Diff line change 42
42
rm -rf $OUTBINDIR $OUTPKGDIR > /dev/null 2>&1
43
43
mkdir -p $OUTBINDIR $OUTPKGDIR
44
44
45
+ # The container will be run as the current user to ensure files
46
+ # written back to the host image are owned by that person instead of root.
47
+ uid=` id -u`
48
+ gid=` id -g`
49
+
45
50
# Mount an output directory
46
51
# Delete the container once it's done its job
47
52
docker run --rm \
48
- -v $OUTBINDIR :$GOPATH /bin:z \
49
- -v $OUTPKGDIR :$GOPATH /pkg:z \
53
+ --user $uid :$gid \
54
+ -v $OUTBINDIR :$GOPATH /bin \
55
+ -v $OUTPKGDIR :$GOPATH /pkg \
50
56
$TAG :$VER
51
57
echo " Compiled samples should now be in $OUTBINDIR "
52
58
fi
You can’t perform that action at this time.
0 commit comments