Is anyone facing docker build error in yarn build

  • Grafana 8.2, Mac OS monterey (Mac M1)

  • ** Build a docker image on Mac OS M1

  • ** docker build --build-arg “GRAFANA_VERSION=latest” --platform linux/arm64 -t custom -f Dockerfile .

  • Getting docker build error in yarn build

[+] Building 289.2s (44/48)                                                                                                                                                                                 
 => [internal] load build definition from Dockerfile                                                                                                                                                   0.0s
 => => transferring dockerfile: 120B                                                                                                                                                                   0.0s
 => [internal] load .dockerignore                                                                                                                                                                      0.0s
 => => transferring context: 118B                                                                                                                                                                      0.0s
 => [internal] load metadata for docker.io/library/alpine:3.14.3                                                                                                                                      22.4s
 => [internal] load metadata for docker.io/library/golang:1.17.3-alpine3.14                                                                                                                           23.3s
 => [internal] load metadata for docker.io/library/node:16-alpine3.14                                                                                                                                 23.3s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                                                            0.0s
 => [auth] library/alpine:pull token for registry-1.docker.io                                                                                                                                          0.0s
 => [auth] library/golang:pull token for registry-1.docker.io                                                                                                                                          0.0s
 => [go-builder  1/13] FROM docker.io/library/golang:1.17.3-alpine3.14@sha256:55da409cc0fe11df63a7d6962fbefd1321fedc305d9969da636876893e289e2d                                                         0.0s
 => [internal] load build context                                                                                                                                                                      0.9s
 => => transferring context: 1.59MB                                                                                                                                                                    0.7s
 => [stage-2  1/13] FROM docker.io/library/alpine:3.14.3@sha256:635f0aa53d99017b38d1a0aa5b2082f7812b03e3cdb299103fe77b5c8a07f1d2                                                                       0.0s
 => [js-builder  1/13] FROM docker.io/library/node:16-alpine3.14@sha256:60ef0bed1dc2ec835cfe3c4226d074fdfaba571fd619c280474cc04e93f0ec5b                                                               0.0s
 => CACHED [stage-2  2/13] WORKDIR /usr/share/grafana                                                                                                                                                  0.0s
 => CACHED [stage-2  3/13] RUN apk add --no-cache ca-certificates bash tzdata musl-utils                                                                                                               0.0s
 => CACHED [stage-2  4/13] RUN apk add --no-cache openssl ncurses-libs ncurses-terminfo-base --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main                                               0.0s
 => CACHED [stage-2  5/13] RUN apk upgrade ncurses-libs ncurses-terminfo-base --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main                                                              0.0s
 => CACHED [stage-2  6/13] RUN apk info -vv | sort                                                                                                                                                     0.0s
 => CACHED [stage-2  7/13] COPY conf ./conf                                                                                                                                                            0.0s
 => CACHED [stage-2  8/13] RUN if [ ! $(getent group "0") ]; then   addgroup -S -g 0 grafana;   fi                                                                                                     0.0s
 => CACHED [stage-2  9/13] RUN export GF_GID_NAME=$(getent group 0 | cut -d':' -f1) &&   mkdir -p "/usr/share/grafana/.aws" &&   adduser -S -u 472 -G "$GF_GID_NAME" grafana &&   mkdir -p "/etc/graf  0.0s
 => CACHED [js-builder  2/13] WORKDIR /grafana                                                                                                                                                         0.0s
 => CACHED [js-builder  3/13] COPY package.json yarn.lock .yarnrc.yml ./                                                                                                                               0.0s
 => CACHED [js-builder  4/13] COPY .yarn .yarn                                                                                                                                                         0.0s
 => CACHED [js-builder  5/13] COPY packages packages                                                                                                                                                   0.0s
 => CACHED [js-builder  6/13] COPY plugins-bundled plugins-bundled                                                                                                                                     0.0s
 => CACHED [js-builder  7/13] RUN yarn install                                                                                                                                                         0.0s
 => CACHED [js-builder  8/13] COPY tsconfig.json .eslintrc .editorconfig .browserslistrc .prettierrc.js babel.config.json ./                                                                           0.0s
 => CACHED [js-builder  9/13] COPY public public                                                                                                                                                       0.0s
 => CACHED [js-builder 10/13] COPY tools tools                                                                                                                                                         0.0s
 => CACHED [js-builder 11/13] COPY scripts scripts                                                                                                                                                     0.0s
 => CACHED [js-builder 12/13] COPY emails emails                                                                                                                                                       0.0s
 => ERROR [js-builder 13/13] RUN yarn build                                                                                                                                                          264.7s
 => CACHED [go-builder  2/13] RUN apk add --no-cache gcc g++ make                                                                                                                                      0.0s
 => CACHED [go-builder  3/13] WORKDIR /grafana                                                                                                                                                         0.0s
 => CACHED [go-builder  4/13] COPY go.mod go.sum embed.go Makefile build.go package.json ./                                                                                                            0.0s
 => CACHED [go-builder  5/13] COPY cue cue                                                                                                                                                             0.0s
 => CACHED [go-builder  6/13] COPY packages/grafana-schema packages/grafana-schema                                                                                                                     0.0s
 => CACHED [go-builder  7/13] COPY public/app/plugins public/app/plugins                                                                                                                               0.0s
 => CACHED [go-builder  8/13] COPY pkg pkg                                                                                                                                                             0.0s
 => CACHED [go-builder  9/13] COPY scripts scripts                                                                                                                                                     0.0s
 => CACHED [go-builder 10/13] COPY cue.mod cue.mod                                                                                                                                                     0.0s
 => CACHED [go-builder 11/13] COPY .bingo .bingo                                                                                                                                                       0.0s
 => CACHED [go-builder 12/13] RUN go mod verify                                                                                                                                                        0.0s
 => CANCELED [go-builder 13/13] RUN make build-go                                                                                                                                                    264.8s
------                                                                                                                                                                                                      
 > [js-builder 13/13] RUN yarn build:                                                                                                                                                                       
------                                                                                                                                                                                                      
executor failed running [/bin/sh -c yarn build]: exit code: 129

Solution for the Issue executor failed running [/bin/sh -c yarn build]: exit code: 129

Might be due to Yarn parallelism. I solved by Increasing Docker CPU: 4, Mem: 4GB, Swap: 4GB.

and added

RUN export NODE_OPTIONS="--max-old-space-size=8192"

to the Docker file.