Skip to content

Commit

Permalink
fix: Does not compile in docker under Apple Silicon
Browse files Browse the repository at this point in the history
fixes #33
  • Loading branch information
boukeversteegh committed Apr 22, 2022
1 parent 033f7dd commit 72e0af9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/dockerized
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,21 @@ 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" \
-v "${DOCKERIZED_ROOT}/build:/build" \
-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"
Expand Down

0 comments on commit 72e0af9

Please sign in to comment.