Docker Build - Failed download from github

I’m having an issue in the build phase of my deployment where my npm install script requires downloads from github - linux-arm64-57_binding.node & phantomjs-2.1.1-linux-x86_64.tar.bz2. I’ve been able to build my image successfully using docker on my local machine and have compared the loggings from the two. Any idea why building my local docker image succeeds while it fails during my resin build?

SUCCESSFUL LOCAL DOCKER BUILD

> node-sass@4.7.2 install /usr/src/app/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.7.2/linux-x64-57_binding.node
Download complete  ] - :
Binary saved to /usr/src/app/node_modules/node-sass/vendor/linux-x64-57/binding.node
Caching binary to /root/.npm/node-sass/4.7.2/linux-x64-57_binding.node

> phantomjs-prebuilt@2.1.16 install /usr/src/app/node_modules/phantomjs-prebuilt
> node install.js

PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2

UNSUCCESSFUL RESIN DOCKER BUILD
[main] > node-sass@4.7.2 install /usr/src/app/node_modules/node-sass
[main] > node scripts/install.js
[main] Downloading binary from { SAME GITHUB LINK AS SUCCESSFUL BUILD - I can’t include more than 2 links b/c I’m a new user }
[main] Cannot download { SAME GITHUB LINK AS SUCCESSFUL BUILD }
[main] HTTP error 404 Not Found
[main] Hint: If github.com is not accessible in your location
[main] try setting a proxy via HTTP_PROXY, e.g.
[main] export HTTP_PROXY=http://example.com:1234
[main] or configure npm proxy via
[main] npm config set proxy http://example.com:8080
[main]
[main] > phantomjs-prebuilt@2.1.16 install /usr/src/app/node_modules/phantomjs-prebuilt
[main] > node install.js
[main] PhantomJS not found on PATH
[main] Unexpected platform or architecture: linux/arm64
[main] It seems there is no binary available for your platform/architecture
[main] Try to install PhantomJS globally

Hi. Can you maybe share your Dockerfile with us?

FROM node:8

RUN apt-get update && apt-get install -yq \
    alsa-utils libasound2-dev && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

COPY package.json package.json

RUN JOBS=MAX npm install --only=dev && npm cache clean --force && rm -rf /tmp/*

COPY . ./

ENV INITSYSTEM on

EXPOSE 4200

CMD ["npm", "start"]

And this is my package.json -

{
  "name": "my-project",
  "version": "1.0.0",
  "private": true,
  "description": "My Project",
  "scripts": {
    "ng": "ng",
    "build": "ng build",
    "start": "ng serve",
    "test": "ng test",
    "lint": "tslint ./src/**/*.ts -t verbose",
    "e2e": "ng e2e"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/animations": "~5.0.0",
    "@angular/common": "~5.0.0",
    "@angular/compiler": "~5.0.0",
    "@angular/compiler-cli": "~5.0.0",
    "@angular/core": "~5.0.0",
    "@angular/forms": "~5.0.0",
    "@angular/http": "~5.0.0",
    "@angular/platform-browser": "~5.0.0",
    "@angular/platform-browser-dynamic": "~5.0.0",
    "@angular/platform-server": "~5.0.0",
    "@angular/router": "~5.0.0",
    "@angular/upgrade": "~5.0.0",
    "angular-in-memory-web-api": "~0.5.0",
    "bootstrap": "^4.0.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "1.6.5",
    "@types/jasmine": "~2.8.0",
    "@types/jasminewd2": "^2.0.3",
    "@types/node": "^6.0.45",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-coverage-istanbul-reporter": "^1.3.3",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-phantomjs-launcher": "^1.0.2",
    "lodash": "^4.16.2",
    "phantomjs-prebuilt": "^2.1.7",
    "protractor": "~5.1.0",
    "ts-node": "^3.3.0",
    "tslint": "^3.15.1",
    "typescript": "2.4.2"
  },
  "repository": {}
}

What device are you deploying to? There might be issues with the architecture x86/x64, ARM?

Have you tried using a resin base image? You can see more about these base images here: https://docs.resin.io/reference/base-images/resin-base-images/

You can pick a node base image and try with that one.

Also, have a look here also: https://docs.resin.io/learn/develop/dockerfile/#dockerfile-templates

I’m deploying to a raspberry3, which has an architecture of armv7hf (https://docs.resin.io/learn/develop/dockerfile/#dockerfile-templates)

Thanks, I took a look at the base images for node and wasn’t able to find the correct one. I tried the following base images - resin/armv7hf-node, resin/raspberrypi3-node, resin/raspberrypi3-node:onbuild, resin/raspberrypi3-alpine-node, resin/raspberrypi3-fedora-node, resin/raspberry-pi2-fedora-node, resin/raspberry-pi2-node, resin/raspberry-pi2-alpine-node, resin/raspberry-pi2-fedora-node.

And here’s my current docker file

FROM resin/raspberry-pi2-fedora-node

RUN apt-get update && apt-get install -yq \
    alsa-utils libasound2-dev && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

COPY package.json package.json

RUN JOBS=MAX npm install --only=dev && npm cache clean --force && rm -rf /tmp/*

COPY . /usr/src/app

ENV INITSYSTEM on

EXPOSE 4200

CMD ["npm", "start"]

Do you think it still may be a base image issue?

You can use

FROM resin/%%RESIN_MACHINE_NAME%%-node

when you use a Dockerfile.template

Can you do that change and paste the Dockerfile.template entirely and the error again you get with it please?

Thanks for all the help so far. I moved my Dockerfile to a Dockerfile.template. Here it is -

FROM resin/%%RESIN_MACHINE_NAME%%-node

RUN apt-get update && apt-get install -yq \
    alsa-utils libasound2-dev && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /usr/src/app

COPY package.json package.json

RUN JOBS=MAX npm install --only=dev && npm cache clean --force && rm -rf /tmp/*

COPY . /usr/src/app

ENV INITSYSTEM on

EXPOSE 4200

CMD ["npm", "start"]

Below is the log output on the line that fails, RUN JOBS=MAX npm install --only=dev && npm cache clean --force && rm -rf /tmp/*

[main]  Step 5/9 : RUN JOBS=MAX npm install --only=dev && npm cache clean --force && rm -rf /tmp/*
[main]   ---> Running in f5422987fe62
[main]  > node-sass@4.7.2 install /usr/src/app/node_modules/node-sass
[main]  > node scripts/install.js
[main]  Downloading binary from https://github.com/sass/node-sass/releases/download/v4.7.2/linux-arm-59_binding.node
[main]  Cannot download "https://github.com/sass/node-sass/releases/download/v4.7.2/linux-arm-59_binding.node":
[main]  HTTP error 404 Not Found
[main]  Hint: If github.com is not accessible in your location
[main]        try setting a proxy via HTTP_PROXY, e.g.
[main]        export HTTP_PROXY=http://example.com:1234
[main]  or configure npm proxy via
[main]        npm config set proxy http://example.com:8080
[main]
[main]  > phantomjs-prebuilt@2.1.16 install /usr/src/app/node_modules/phantomjs-prebuilt
[main]  > node install.js
[main]  PhantomJS not found on PATH
[main]  Unexpected platform or architecture: linux/arm
[main]  It seems there is no binary available for your platform/architecture
[main]  Try to install PhantomJS globally
[main]
[main]  npm
[main]   WARN ajv-keywords@3.1.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
[main]
[main]  npm WARN
[main]  optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
[main]  npm WARN
[main]   notsup
[main]   SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})
[main]
[main]
[main]
[main]  npm ERR! code
[main]   ELIFECYCLE
[main]
[main]  npm ERR! errno
[main]   1
[main]
[main]  npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
[main]
[main]  npm
[main]
[main]  ERR!
[main]   Exit status 1
[main]
[main]  npm ERR!
[main]
[main]  npm
[main]
[main]  ERR!
[main]   Failed at the phantomjs-prebuilt@2.1.16 install script.
[main]  npm ERR!
[main]   This is probably not a problem with npm. There is likely additional logging output above.
[main]
[main]
[main]
[main]  npm
[main]  ERR!
[main]   A complete log of this run can be found in:
[main]
[main]  npm
[main]  ERR!     /root/.npm/_logs/2018-03-22T02_10_39_729Z-debug.log
[main]
[main]  Removing intermediate container f5422987fe62
[main]  The command '/bin/sh -c JOBS=MAX npm install --only=dev && npm cache clean --force && rm -rf /tmp/*' returned a non-zero code: 1

Is https://github.com/sass/node-sass/releases/download/v4.7.2/linux-arm-59_binding.node supposed to be available? Because apparently it is not. @nghiant2710 do you have experience with node-sass?

Can you also paste your package.json file contents please?

Thanks for the pointer, I’ll investigate. And the package.json is above in an earlier post after the first docker file.

I think I need to find the correct base image compatible with my platform architecture. This seems to be the issue with phantomJS and I’m hoping that solving this will also solve the SASS issue.

SASS Issue
FROM node:8 (https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2)

> node-sass@4.8.3 install /usr/src/app/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.8.3/linux-x64-57_binding.node
Download complete

FROM resin/%%RESIN_MACHINE_NAME%%-node (https://github.com/sass/node-sass/releases/download/v4.8.3/linux-x64-57_binding.node)

> node-sass@4.8.3 install /usr/src/app/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.8.3/linux-arm-59_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.8.3/linux-arm-59_binding.node":

PhantomJS Issue

FROM node:8

PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2

FROM resin/%%RESIN_MACHINE_NAME%%-node

> phantomjs-prebuilt@2.1.16 install /usr/src/app/node_modules/phantomjs-prebuilt
> node install.js

PhantomJS not found on PATH
Unexpected platform or architecture: linux/arm
It seems there is no binary available for your platform/architecture
Try to install PhantomJS globally

Hey @DavidStreid it looks as if arm releases for sass are not provided: https://github.com/sass/node-sass/releases/

Ahh that explains it, thanks. The @angular/cli looks like it does include this as a dependency. My project doesn’t have any sass, but I would like to remove this dependency. Do you think my assessment is correct? And if it is, is there a way to remove @angular/cli’s dependency on node-sass & sass-loader? Both install other sass dependencies.

From package-lock.json -

  {
    "name": "my-app",
    "version": "1.0.0",
    "lockfileVersion": 1,
    "requires": true,
    "dependencies": {
      ...
      "@angular/cli": {
        "version": "1.6.5",
        "resolved": "https://registry.npmjs.org/@angular/cli/-/cli-1.6.5.tgz",
        "integrity": "sha512-YyGdq7rM1xduSdxviKfbd9NsYloEIeK3T+WEftsHSlViKuNQh8jIUoMzTGypjCmTieE2Gtg5BnukaxuUo1G+bQ==",
        "dev": true,
        "requires": {
          …
          "node-sass": "4.8.3",
          …
          "sass-loader": "6.0.7",
          …
        }
  …

Hi @DavidStreid
My recommendation here would be to fork the @angular/cli project on GitHub, checkout a new branch and remove the sass dependency and then add your forked repo as a dependency to your project using a GIT url.

I see that you are depending on v1.6.5 of @angular/cli, so you need to use the 1.6.x branch.
After forking, your .package.json should look something like this:

  {
    "name": "my-app",
    "version": "1.0.0",
    "lockfileVersion": 1,
    "requires": true,
    "dependencies": {
      "@angular.cli": "GITHUB_USERNAME/angular-cli#1.6.x-modified"
    }
}

Hi @DavidStreid
My recommendation here would be to fork the @angular/cli project on GitHub, checkout a new branch and remove the sass dependency and then add your forked repo as a dependency to your project using a GIT url.
I see that you are depending on v1.6.5 of @angular/cli, so you need to use the 1.6.x branch.
After forking, your .package.json should look something like this:
{

“name”: “my-app”,

“version”: “1.0.0”,

“lockfileVersion”: 1,

“requires”: true,

“dependencies”: {

@angular.cli”: “GITHUB_USERNAME/angular-cli#1.6.x-modified”

}

}