How to pre-install stack dependencies, to reduce stack build time? - haskell-stack

I'm building a docker image from a Haskell application, I'm executing stack build from within the container.
Because stack build is starting from a 'fresh/vanilla' docker image - all the libraries need to be installed/pulled.
Is there a way I can pre-install these library dependencies? For the end goal of reducing the docker image build time (stack build). I'd also like to be able to later on 'add' an additional dependency without having to once again stack build everything over from start.
A possible solution:
I tried a series of:
RUN stack install --only-dependencies --resolver="lts-14.27" aeson
RUN stack install --only-dependencies --resolver="lts-14.27" aeson-pretty
RUN stack install --only-dependencies --resolver="lts-14.27" ansi-terminal
RUN stack install --only-dependencies --resolver="lts-14.27" ansi-wl-pprint
RUN stack install --only-dependencies --resolver="lts-14.27" appar
RUN stack install --only-dependencies --resolver="lts-14.27" array
RUN stack install --only-dependencies --resolver="lts-14.27" asn1-encoding
RUN stack install --only-dependencies --resolver="lts-14.27" asn1-parse
RUN stack install --only-dependencies --resolver="lts-14.27" asn1-types
RUN stack install --only-dependencies --resolver="lts-14.27" async
RUN stack install --only-dependencies --resolver="lts-14.27" attoparsec
RUN stack install --only-dependencies --resolver="lts-14.27" authenticate-oauth
RUN stack install --only-dependencies --resolver="lts-14.27" auto-update
RUN stack install --only-dependencies --resolver="lts-14.27" base
RUN stack install --only-dependencies --resolver="lts-14.27" base-compat
RUN stack install --only-dependencies --resolver="lts-14.27" base-orphans
RUN stack install --only-dependencies --resolver="lts-14.27" base16-bytestring
However this has several limitations:
dependencies are built sequentially (and hence slower)
a side effect of also installing any executable related to this library. - resulting Docker image is enormous - 67GB:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> d2a95ef3622d 11 seconds ago 67GB

This seems to do it:
stack build --only-dependencies

One can manually install the dependencies in a single step with something like :
stack install --resolver lts-14.27 Cabal Only RSA SHA StateVar adjunctions aeson ...

Related

Update globally installed packages in `$GOPATH/bin`

If I install a node package globally with npm i -g aoeu, I can update this package by running npm update -g aoeu, and I can update all my globally installed packages by running npm update -g.
Now, if I install a Go package to my $GOPATH/bin with go install GitHub.com/aoeu#latest, how can I update all these globally installed packages?
Now, if I install a Go package to my $GOPATH/bin with go install GitHub.com/aoeu#latest, how can I update all these globally installed packages?
You can't, except to update each one individually. There's no mechanism for this in Go. The files in this directory are not tracked in any way.

Puppeteer installation has error

I have problem with puppeteer. I cannot install it on my debian 8.7.1.
These are the steps:
1.install chrome:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get -f install
sudo dpkg -i google-chrome-stable_current_amd64.deb
2.install nodejs & puppeteer:
apt-get install curl
curl -sL https://deb.nodesource.com/setup_8.x | bash -
sudo apt-get install -y nodejs
npm i puppeteer
When I run npm i puppeteer, the errors are:
> puppeteer#0.11.0 install /root/node_modules/puppeteer
> node install.js
ERROR: Failed to download Chromium r499413! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
Error: Download failed: server returned code 403. URL: https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/499413 /chrome-linux.zip
at ClientRequest.https.get.response (/root/node_modules/puppeteer/utils/ChromiumDownloader.js:195:21)
at Object.onceWrapper (events.js:316:30)
at emitOne (events.js:115:13)
at ClientRequest.emit (events.js:210:7)
at HTTPParser.parserOnIncomingClient (_http_client.js:565:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
at TLSSocket.socketOnData (_http_client.js:454:20)
at emitOne (events.js:115:13)
at TLSSocket.emit (events.js:210:7)
at addChunk (_stream_readable.js:266:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! puppeteer#0.11.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the puppeteer#0.11.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-10-04T12_32_37_607Z-debug.log
I run the command npm config set PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true to skip download but it wants to download chromium yet.
Any idea to solve this problem?
Try below options;
1) npm config set puppeteer_skip_chromium_download true
2) Add puppeteer_skip_chromium_download=true to .npmrc file where the package.json location
After that run sudo npm install --unsafe-perm=true --allow-root
References;
https://github.com/GoogleChrome/puppeteer/issues/2270
https://medium.com/forcit/seo-for-single-page-applications-8543619e1d0c
upgrade your puppeteer version (optional)
npm set strict-ssl false
npm config set puppeteer_skip_chromium_download true
and npm install again.
try
sudo npm install puppeteer --unsafe-perm=true
Error: spawn EACCES
This roughly means that puppeteer cannot execute Chrome due to permissions issues. If you're having troubles I have a docker image here that you can use and interact with remotely. The issue with Chrome and many linux distros is that installation is quite a challenge to solve.
If you have chrome already you can use system variable to skip installation
https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#environment-variables
I faced a similar issue when I was using Puppeteer.
I see two parts to your problem,
1. The inability to download Chromium and getting 403 error other is
2. Error: spawn EACCES problem
I'll start with Error: spawn EACCES problem as it's more subtle and tricky
This is because your debian machine doesn't have the required dependencies installed in order to run Puppeteer. These dependencies differ between distributions(CentOS, Ubuntu/Debian etc...).
Follow these steps,
Install all the dependencies required. You can refer this link for the list, https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix
After all the dependencies are installed, install npm and configure proxy in .npmrc if you are behind a VPC/proxy.
Then, as usual, go ahead with npm i puppeteer and proceed as always
Next to address your inability to download Chromium problem.
Are you behind a proxy? That was my issue.
I noticed on executing npm i puppeteer the script downloads Chromium from an external URL which from your log is https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/499413/chrome-linux.zip
npm is unable to download from this external URL because of the proxy blocking it.
The way I solved this issue was by configuring .npmrc file with the proxy settings
npm config set proxy http://<proxy_username>:<proxy_passowrd>#<proxy_host>:<proxy_port>
npm config set https-proxy http://<proxy_username>:<proxy_passowrd>#<proxy_host>:<proxy_port>
Note:
If your username/password contains any special characters you need to URL encode them. Eg. If your username is bruce\wayne then you need to URL encode it as bruce%5Cwayne where %5C="\"
If your proxy has no authentication then ignore and
Examples:
npm config set proxy http://bruce%5Cwayne:darkknight#11.434.2.23:8080
npm config set https-proxy http://bruce%5Cwayne:darkknight#11.434.2.23:8080
So, try configuring your .npmrc file using the commands given above and then try running npm i puppeteer. The proxy will no longer be blocking the external URL and you would be able to download Chromium.
Let me know if this works and reach out to me if you have any doubts.
I have faced similar issue. The best work around for this is to create a project using npm init, then install puppeteer using command "npm install puppeteer --save". This way chromium also gets installed with out any issues.Hope this helps..
Please set the following in .npmrc
puppeteer_download_host = https://npm.taobao.org/mirrors
or
npm config set puppeteer_download_host https://npm.taobao.org/mirrors

Install Ionic Cordova Error

I am trying to install Ionic 2 on a OSx machine. I did install Node.js. When I run the following:
$ npm install -g ionic cordova
I get this error:
If anyone can assist, I would appreciate it.
UPDATE:
Downgraded Node to v6.9.1 and still get the same error:
UPDATE
As suggested below, I tried:
npm cache clean
But still get the same error:
UPDATE
If I try install a specific version, I get the following error:
sudo npm install -g ionic#2.0.0-beta.20 cordova
to install ionic in mac
you have to install nodejs .
to install ionic as per the official doc if you are using linux or mac you should use sudo command
try
sudo npm install -g ionic cordova
note
your npm version should be greater then 3.x
that version of node its the current so maybe its nos stable at all. I recommend to instal NVM (node version manager) from here this is like a "sand-box" where you have all node version you want and can switch between them.
You only need to run nvm install 5.11.0 and nvm will download that node version for you. Then to use a specific node version you need to run nvm use 5.11.0 and thats all.
I recommend to install 5.11.0 for example, its the node version that im using atm and its working fine with ionic2 RC3.
After downgrading your node.js clean npm cache.
npm cache clean
and try the installation again

Installing docpad#6.63 error: No compatible version found: taskgroup#'~3.3.7n'

I'm trying to install docpad and following the guide on: http://docpad.org/docs/install
When I issue the command:
npm install -g docpad#6.63
I get the following npm error:
npm ERR! Error: No compatible version found: taskgroup#'~3.3.7n'
npm ERR! Valid install targets:
npm ERR! ["2.0.0","3.0.0","3.1.0","3.1.1","3.1.2","3.2.0","3.2.2","3.2.3","3.2.4","3.3.0","3.3.1","3.3.2","3.3.3","3.3.4","3.3.5","3.3.6","3.3.7","3.3.8"]
My node version: v0.10.15
My npm version: 1.2.18
I'm running Kubuntu 13.10 with all updates.
I checked if there is an issue reported for this on github, there isn't. Should I report this as an issue or am I doing something wrong?
Same problem here (Kubuntu 13.10).
I sugggest to go back to a previous version of docpad for the moment. On Ubunto/Debian there is another pitfall: some node modules depend on the nodejs executable to be available under node, so you need the additional package nodejs-legacy.
This worked for me:
sudo apt-get install nodejs-legacy
npm install docpad#6.55.6
Bug on DocPad's behalf, that n shouldn't have been there. Now fixed in v6.63.5. Thanks for the report!

fine-uploader example traditional build

So, I'm trying to evaluate fine-uploader. I decided to go to the download page, but it wants you to purchase a license, but I don't want to do that until after I've evaluated it. So, I went to github and downloaded the master zip for it and unzipped. My question is now what? The so-called "step-by-step" are not step-by-step. Am I supposed to build something? The documentation states I just need to include one file....which file? In the demos, for traditional use, i see it includes fineuploader-{VERSION}.js, but I see no file that even starts with "fineuploader" in the subdirectory of "client/js/*".
Am I just missing the documentation for this completely?
Thanks!
Following Bjørn Børresen's answer, the official documentation (which is severely lacking) and some troubleshooting, I was successfull on Ubuntu 13.10 with the following commands:
sudo apt-get install npm git
sudo npm install -g npm
sudo npm install -g grunt-cli
sudo npm install -g bower
git clone https://github.com/Widen/fine-uploader.git
cd fine-uploader
npm install http://github.com/e-jigsaw/grunt/tarball/fix-underscore-string-version
bower install
sudo npm install -g
npm install grunt
npm install
grunt package
You'll need git, NPM, Grunt & Bower.
Assuming you have git, if not install it. Then navigate to http://nodejs.org/ and INSTALL NodeJS.
From the command line:
npm install -g grunt-cli
npm install -g bower
git clone git#github.com:Widen/fine-uploader.git
cd fine-uploader
bower install
npm install -g
grunt
These are the steps that worked for me on Windows 7:
I. Install Prereqs (should only be necessary the first time)
Install node.js on windows if you haven't already.
Ensure npm has been added to your PATH variable (as of this writing, node.js puts this in during install):
%USERPROFILE%\AppData\Roaming\npm
Install git on windows if you haven't already.
Ensure the git commands have been added to your PATH variable (as of this writing the git install does not add these):
C:\Program Files(x86)\Git\bin;C:\Program Files (x86)\Git\cmd
Open command prompt.
Install grunt globally:
npm install -g grunt
Install grunt-cli globally:
npm install -g grunt-cli
Clone the repo if you haven't already:
git clone git://github.com/Widen/fine-uploader
Change command prompt directory to repo location (most likely at %USERPROFILE%\fine-uploader).
Install dependencies (if you want the dependencies installed
globally add a -g below but it is not necessary):
npm install
II. Build and Package
Open command prompt at the repo location (i.e. %USERPROFILE%\fine-uploader)
Pull latest, if necessary:
git pull
package it up:
grunt package
This should result in the files being added to the _dist folder in your repo.
The build and distribution methods have changed quite a bit over the past couple years. As of Fine Uploader 5.11, you have the following options:
Download Fine Uploader from npm
npm install fine-uploader
Download Fine Uploader from the project's home page
...at http://fineuploader.com/customize
Build Fine Uploader yourself from the GitHub repo
git clone https://github.com/FineUploader/fine-uploader.git
cd fine-uploader
npm install
make build
The "contribute code" section in the README contains even more details.

Resources