From 94928c61477afc08a8bca1d598b31e01f9d5e146 Mon Sep 17 00:00:00 2001 From: Bouke Versteegh Date: Fri, 22 Apr 2022 17:52:56 +0200 Subject: [PATCH] fix: Does not compile in docker under Apple Silicon fixes #33 --- bin/dockerized | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/dockerized b/bin/dockerized index 105ebd4..0d1f8e1 100755 --- a/bin/dockerized +++ b/bin/dockerized @@ -70,9 +70,13 @@ if [ "$DOCKERIZED_COMPILE" ] || [ ! -f "$DOCKERIZED_BINARY" ]; then GO_BUILD_ARGS="-ldflags '-X main.Version=${GIT_COMMIT}'" GO_LDFLAGS="-X main.Version=${GIT_COMMIT}" if [ "${DOCKERIZED_COMPILE:-docker}" == "docker" ]; then + rm -f "$DOCKERIZED_BINARY" + CMD_BUILD="go build -ldflags \"$GO_LDFLAGS\" -o //build/ ." + # Fix permissions of compiled binary (Linux and MacOS) + CMD_CHOWN="chown $(id -u):$(id -g) //build/$(basename $DOCKERIZED_BINARY)" + CMD_CHMOD="chmod +x //build/$(basename $DOCKERIZED_BINARY)" docker run \ --rm \ - --entrypoint=go \ -e "GOOS=${DOCKERIZED_COMPILE_GOOS}" \ -e "GOARCH=${DOCKERIZED_COMPILE_GOARCH}" \ -v "${DOCKERIZED_ROOT}:/src" \ @@ -80,7 +84,7 @@ if [ "$DOCKERIZED_COMPILE" ] || [ ! -f "$DOCKERIZED_BINARY" ]; then -v "${DOCKERIZED_ROOT}/.cache:/go/pkg" \ -w //src \ "golang:1.17.8" \ - build -ldflags "$GO_LDFLAGS" -o //build/ . + bash -c "$CMD_BUILD && $CMD_CHOWN && $CMD_CHMOD" else ( cd "$DOCKERIZED_ROOT"