'npm run test' works completely fine on the server or on my local but its failing on my docker machine. I am bit new to this docker world so I am just confused about whats going wrong here. I was getting the error:
Post stage
[32m15 07 2018 18:41:35.164:INFO [karma]: [39mKarma v1.2.0 server started at http://localhost:9876/
[32m15 07 2018 18:41:35.169:INFO [launcher]: [39mLaunching browser ChromeHeadless with unlimited concurrency
[32m15 07 2018 18:41:35.185:INFO [launcher]: [39mStarting browser ChromeHeadless
[31m15 07 2018 18:41:35.186:ERROR [launcher]: [39mNo binary for ChromeHeadless browser on your platform.
Please, set "CHROME_BIN" env variable.
Finished in 0 secs / 0 secs @ 18:41:35 GMT+0000 (UTC)
npm ERR! code ELIFECYCLE
Somewhere I found that, it might be missing chrome.. so I installed chrome manually inside my docker:
# install manually all the missing libraries
RUN apt-get install -y gconf-service libasound2 libatk1.0-0 libcairo2 libcups2 libfontconfig1 libgdk-pixbuf2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libxss1 fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils
# install chrome
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install
Then I set the chrome environment variable inside the docker using: export CHROME_BIN=/usr/bin/google-chrome
But still when I run npm test, it fails with this error:
15 07 2018 19:20:46.291:INFO [launcher]: Starting browser ChromeHeadless 15% building modules 45/51 modules 6 active ...iv2/node_modules/zone.js/dist/zone.js15 07 2018 19:20:46.964:ERROR [launcher]: Cannot start ChromeHeadless
19% building modules 79/79 modules 0 active15 07 2018 19:20:47.750:INFO [launcher]: Trying to start ChromeHeadless again (1/2). 20% building modules 84/90 modules 6 active ...ode_modules/webpack/buildin/global.js15 07 2018 19:20:48.097:ERROR [launcher]: Cannot start ChromeHeadless
20% building modules 91/98 modules 7 active ...node_modules/angular2-moment/index.js15 07 2018 19:20:48.166:INFO [launcher]: Trying to start ChromeHeadless 22% building modules 103/156 modules 53 active ...s/rxjs/_esm5/operator/timeInterval.js15 07 2018 19:20:49.199:ERROR [launcher]: Cannot start ChromeHeadless
23% building modules 110/181 modules 71 active ...amic/esm5/platform-browser-dynamic.js15 07 2018 19:20:50.050:ERROR [launcher]: ChromeHeadless failed 2 times (cannot start). Giving up.
Finished in 0 secs / 0 secs @ 19:20:50 GMT+0000 (UTC)
23% building modules 111/185 modules 74 active ...e_modules/angular2-cookie/services.js
Anyone has any idea how I can solve this. Please note, this is happening inside my docker and my base docker image is 'python:2.7.13-slim'
Instead of export
ing the variable, can you try setting it with
ENV CHROME_BIN=/usr/bin/google-chrome
Generally, setting environment variables with ENV is recommended, see here for a more detailed discussion.
The docker run command accepts env file by the -env-file
flag.
So, you can add a new env file with the following
CHROME_BIN=/usr/bin/google-chrome
and pass this file to docker run command
docker run --env-file ./env.list -t -d ${BUILD_NAME}
refer here for the official docs
This way, we don't puppeteer just to set the env variable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With