Yarn install fails when building Grafana using docker file

I have taken the source code of Grafana from Github version : 8.5.10 in my VirtualBox Ubuntu machine.
When I tried to build a docker image without changing anything in the source code, I am getting errors with yarn install.

The commands I used to build a docker image is

docker build -f Dockerfile -t grafana:8.5.10 .
or
make build-docker-full

This command gave the bellow errors:

➤ YN0013: │ zwitch@npm:1.0.5 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed in 8m 14s
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ cypress@npm:9.5.1 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js@npm:3.21.1 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js-pure@npm:3.21.1 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js-pure@npm:3.19.0 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js@npm:2.6.12 must be built because it never has been before or the last one failed
➤ YN0007: │ protobufjs@npm:6.11.3 must be built because it never has been before or the last one failed
➤ YN0007: │ nodemon@npm:2.0.15 must be built because it never has been before or the last one failed
➤ YN0009: │ cypress@npm:9.5.1 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-762d155f/build.log)
➤ YN0009: │ protobufjs@npm:6.11.3 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-12a4a5cd/build.log)
➤ YN0007: │ grafana@workspace:. must be built because it never has been before or the last one failed
➤ YN0009: │ grafana@workspace:. couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-3e6a6476/build.log)
➤ YN0000: └ Completed in 38s 529ms
<strong>➤ **YN0000: Failed with errors in 8m 59s**
The command '/bin/sh -c yarn install' returned a non-zero code: 1</strong>
make: *** [Makefile:153: build-docker-full] Error 1

Can you please help here on resolving this issue

The logs are

cicd:~# cat /var/lib/docker/overlay2/73c0b29fbe5f859a3ac3384e51a3e87662c88e90499cb96b9aa5e190683ce18c/diff/tmp/xfs-43adc80f/build.log
# This file contains the result of Yarn building a package (grafana@workspace:.)
# Script name: postinstall

(node:133) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/errors:478
    ErrorCaptureStackTrace(err); 
    ^ 

Error [ERR_LOADER_CHAIN_INCOMPLETE]: "file:///grafana/.pnp.loader.mjs 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include `shortCircuit: true` in the hook's return.
    at new NodeError (node:internal/errors:387:5) 
    at ESMLoader.resolve (node:internal/modules/esm/loader:845:13) 
    at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:7) 
    at async Promise.all (index 0) 
    at async ESMLoader.import (node:internal/modules/esm/loader:526:24) 
    at async loadESM (node:internal/process/esm_loader:91:5) 
    at async handleMainPromise (node:internal/modules/run_main:65:12) { 
  code: 'ERR_LOADER_CHAIN_INCOMPLETE' 
}

Hi @ajunivn,

Welcome to the :grafana: community support forums !!

Not sure, but did you use the following link when building Grafana?

Below is a different link (from the same page) that includes a section Add data sources which explains some starting points when using Docker.

Let us know if this helps.

Hello, friend! how did you solve the build problem in docker?

Hi @levakesh,

Did you already check the above link which contains information on how to build Grafana?

Thanks

Hi usmangt
Followed the link which you have been mentioned earlier(grafana/developer-guide.md at main · grafana/grafana · GitHub) but still I am unable to build docker image. Could you please suggest solution on this below error.

➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ cypress@npm:9.5.1 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js@npm:3.21.1 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js-pure@npm:3.21.1 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js-pure@npm:3.19.0 must be built because it never has been before or the last one failed
➤ YN0007: │ core-js@npm:2.6.12 must be built because it never has been before or the last one failed
➤ YN0007: │ protobufjs@npm:6.11.3 must be built because it never has been before or the last one failed
➤ YN0007: │ nodemon@npm:2.0.15 must be built because it never has been before or the last one failed
➤ YN0009: │ cypress@npm:9.5.1 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-ea92e23d/build.log)
➤ YN0009: │ protobufjs@npm:6.11.3 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-6343b81a/build.log)
➤ YN0007: │ grafana@workspace:. must be built because it never has been before or the last one failed
➤ YN0009: │ grafana@workspace:. couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-4add8548/build.log)
➤ YN0000: └ Completed in 7s 653ms
➤ YN0000: Failed with errors in 2m 60s

Hi usmangt
Followed the link which you have been mentioned
earlier(https://github.com/grafana/grafana/blob/main/contribute/developer-
guide.md) but still I am unable to build docker image. Could you please
suggest solution on this below error.

My suggestion is to look at the log files referenced in the error messages:

➤ YN0009: │ cypress@npm:9.5.1 couldn’t be built successfully (exit code 1,
logs can be found here: /tmp/xfs-ea92e23d/build.log)

➤ YN0009: │ protobufjs@npm:6.11.3 couldn’t be built successfully (exit code
1, logs can be found here: /tmp/xfs-6343b81a/build.log)

➤ YN0009: │ grafana@workspace:. couldn’t be built successfully (exit code 1,
logs can be found here: /tmp/xfs-4add8548/build.log)

Those should tell you more about what the problem is.

Antony.

1 Like