Open sarvaje opened 6 years ago
My simple Dockerfile:
FROM node:8.9.4-alpine
RUN npm install -g --engine-strict sonarwhal --unsafe-perm=true
WORKDIR /wd/
COPY /.sonarwhalrc /wd/.sonarwhalrc
ENTRYPOINT ["sonarwhal"]
CMD ["http://example.com"]
@SeriyVol4ishe can you share your .sonarwhalrc
file?
I used the default from this repository to test and it works. But I think that need to upgrade Dockerfile if some rules need some specific packages or tools with some configurating.
Please, can you give me an example?
Core rules don't need any extra package, but if you need some specific configuration in a rule, you just need to change the .sonarwhalrc
before create the image.
Is that what you want to avoid?
when I try to use https://github.com/sonarwhal/sonarwhal/blob/master/.sonarwhalrc I have this output:
No configuration found for cloudinary
...
Warning No valid configuration for Cloudinary found. Rule coudn't run. image-optimization-cloudinary
✖ Found 0 errors and 1 warning
I use jsdom as connector because didn't install chrome in container as you can see
when I try to use https://github.com/sonarwhal/sonarwhal/blob/master/.sonarwhalrc I have this output:
No configuration found for cloudinary
That isn't a problem with Docker, you will get the same result if you install sonarwhal
in your computer.
To make it work you have two options:
"image-optimization-cloudinary": "off"
.Similar to @SeriyVol4ishe I've been using the following Dockerfile
for quite some time in our ci process.
FROM node:8.9-alpine
RUN apt-get update && \
apt-get install -y curl apt-transport-https && \
npm install -g --engine-strict sonarwhal --unsafe-perm=true
COPY .sonarwhalrc /
ENTRYPOINT ["sonarwhal"]
CMD ["-h"]
Where the .sonarwhalrc
is the default from --init
. To replace the default; volume mapping or using the above as a base image as shown below.
FROM sonarwhal/sonarwhal:1.0.1
COPY .sonarwhalrc /
Now thinking on this as a official base layer running something like sonarwhal --init
in the dockerfile could streamline it so a template file doesn't need to be copied in. Giving you something like:
FROM node:8.9-alpine
RUN apt-get update && \
apt-get install -y curl apt-transport-https && \
npm install -g --engine-strict sonarwhal --unsafe-perm=true \
echo "predefined\n"web-recommended | ./node_modules/.bin/sonarwhal --init
#echo "custom\njsdom\njson\na\n\n" | ./node_modules/.bin/sonarwhal --init # ensures proper npm installed for any config - needs to be tested
ENTRYPOINT ["sonarwhal"]
CMD ["-h"]
What are the errors you are having?
From: sk3lk0 notifications@github.com Sent: Monday, November 11, 2019 07:02 To: webhintio/hint Cc: Antón Molleda; Team mention Subject: Re: [webhintio/hint] webhint + Docker (#800)
can you give new dockerfile ? other docker files not working
— You are receiving this because you are on a team that was mentioned. Reply to this email directly, view it on GitHubhttps://github.com/webhintio/hint/issues/800?email_source=notifications&email_token=AAEUDASCP7ZWY23ZQQSJGQTQTFXXXA5CNFSM4EPN5S7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDXC3HI#issuecomment-552480157, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAEUDAQW2FKZYSDGW5AYUYLQTFXXXANCNFSM4EPN5S7A.
What are the errors you are having? … ____ From: sk3lk0 notifications@github.com Sent: Monday, November 11, 2019 07:02 To: webhintio/hint Cc: Antón Molleda; Team mention Subject: Re: [webhintio/hint] webhint + Docker (#800) can you give new dockerfile ? other docker files not working — You are receiving this because you are on a team that was mentioned. Reply to this email directly, view it on GitHub<#800?email_source=notifications&email_token=AAEUDASCP7ZWY23ZQQSJGQTQTFXXXA5CNFSM4EPN5S7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDXC3HI#issuecomment-552480157>, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAEUDAQW2FKZYSDGW5AYUYLQTFXXXANCNFSM4EPN5S7A.
my dockerfile is:
FROM node:8.10.0-slim WORKDIR /wd RUN apk update RUN apk add python pkgconfig pixman pixman-dev cairo cairo-dev pango pango-dev make g++ libjpeg libjpeg-turbo-dev RUN npm install hint --save-dev RUN npm install @hint/configuration-all --save-dev RUN npm install @hint/formatter-json --save-dev RUN npm install -g node-pre-gyp --save-dev COPY .hintrc ./
ENTRYPOINT ["npx"]
but i have error:
/ # npx hint -c .hintrc https://example.com module.js:550 throw err; ^
Error: Cannot find module '/root/.npm/_npx/563/lib/node_modules/hint/node_modules/iltorb/scripts/install.js' at Function.Module._resolveFilename (module.js:548:15) at Function.Module._load (module.js:475:25) at Function.Module.runMain (module.js:694:10) at startup (bootstrap_node.js:204:16) at bootstrap_node.js:625:3 gyp ERR! configure error gyp ERR! stack Error: EACCES: permission denied, stat '/root/.npm/_npx/563/lib/node_modules/hint/node_modules/iltorb/.node-gyp/8.16.2' gyp ERR! System Linux 5.0.0-32-generic gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /root/.npm/_npx/563/lib/node_modules/hint/node_modules/iltorb gyp ERR! node -v v8.16.2 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok fs.js:646 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^
Error: EACCES: permission denied, open '/root/.npm/_npx/563/lib/node_modules/hint/node_modules/canvas/package.json' at Object.fs.openSync (fs.js:646:18) at Object.fs.readFileSync (fs.js:551:33) at Run.parseOpts [as parseArgv] (/usr/local/lib/node_modules/node-pre-gyp/lib/node-pre-gyp.js:136:36) at Object. (/usr/local/lib/node_modules/node-pre-gyp/bin/node-pre-gyp:24:6) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Function.Module.runMain (module.js:694:10) module.js:550 throw err; ^
Error: Cannot find module '/root/.npm/_npx/563/lib/node_modules/hint/node_modules/puppeteer-core/install.js' at Function.Module._resolveFilename (module.js:548:15) at Function.Module._load (module.js:475:25) at Function.Module.runMain (module.js:694:10) at startup (bootstrap_node.js:204:16) at bootstrap_node.js:625:3
It would be nice allow the users run webhint in Docker (ref #799).
Ideas:
webhint
. These images will run the wizard by default when you run it.webhint
images and add their own.hintrc
file..hintrc
file.Other ideas will be more than welcome.
//cc @webhintio/contributors