File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 6666
6767if [ " $DOCKERIZED_COMPILE " ] || [ ! -f " $DOCKERIZED_BINARY " ]; then
6868 echo " Compiling dockerized..." >&2
69+ rm -f " $DOCKERIZED_BINARY "
70+
6971 GIT_COMMIT=$( cd $DOCKERIZED_ROOT ; git rev-list -1 HEAD)
7072 GO_BUILD_ARGS=" -ldflags '-X main.Version=${GIT_COMMIT} '"
7173 GO_LDFLAGS=" -X main.Version=${GIT_COMMIT} "
7274 if [ " ${DOCKERIZED_COMPILE:- docker} " == " docker" ]; then
73- rm -f " $DOCKERIZED_BINARY "
75+ # Create a volume for go pkg cache instead of local mount (#33)
76+ DOCKERIZED_COMPILE_VOLUME=" dockerized_compile_${DOCKERIZED_COMPILE_GOOS} _${DOCKERIZED_COMPILE_GOARCH} "
77+ docker volume create --driver local " ${DOCKERIZED_COMPILE_VOLUME} "
78+
7479 CMD_BUILD=" go build -ldflags \" $GO_LDFLAGS \" -o //build/ ."
75- # Fix permissions of compiled binary (Linux and MacOS)
76- CMD_CHOWN=" chown $( id -u) :$( id -g) //build/$( basename $DOCKERIZED_BINARY ) "
77- CMD_CHMOD=" chmod +x //build/$( basename $DOCKERIZED_BINARY ) "
80+ CMD_CHOWN=" chown $( id -u) :$( id -g) //build/$( basename $DOCKERIZED_BINARY ) " # fix permissions (#33)
81+ CMD_CHMOD=" chmod +x //build/$( basename $DOCKERIZED_BINARY ) " # fix executable bit (#33)
7882 docker run \
7983 --rm \
8084 -e " GOOS=${DOCKERIZED_COMPILE_GOOS} " \
8185 -e " GOARCH=${DOCKERIZED_COMPILE_GOARCH} " \
8286 -v " ${DOCKERIZED_ROOT} :/src" \
8387 -v " ${DOCKERIZED_ROOT} /build:/build" \
84- -v " ${DOCKERIZED_ROOT} /.cache :/go/pkg" \
88+ -v " ${DOCKERIZED_COMPILE_VOLUME} :/go/pkg" \
8589 -w //src \
8690 " golang:1.17.8" \
8791 bash -c " $CMD_BUILD && $CMD_CHOWN && $CMD_CHMOD "
You can’t perform that action at this time.
0 commit comments