Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken build and Broken Docker Build #934

Closed
Odyno opened this issue Feb 26, 2018 · 3 comments
Closed

Broken build and Broken Docker Build #934

Odyno opened this issue Feb 26, 2018 · 3 comments

Comments

@Odyno
Copy link
Contributor

Odyno commented Feb 26, 2018

Hello,
I tried to build the project from branch master but it doesn't work me.

Tentative A:
From my mac fail when I tried to build the the project with my local installation ( I followed the instruction here). My Environment:

  • MacOS high Sierra
  • node v6.10.3
  • yarn 1.5.0
  • bower 1.8.2
  • Docker version 17.12.0-ce, build c97c6d6

Responce:

17:43 $ script/bootstrap
yarn install v1.5.0
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 📃  Building fresh packages...
✨  Done in 48.35s.
bower iron-list#^2.0.2          cached https://github.com/PolymerElements/iron-list.git#2.0.12
bower iron-list#^2.0.2        validate 2.0.12 against https://github.com/PolymerElements/iron-list.git#^2.0.2
bower iron-list#^2.0.2         install iron-list#2.0.12

iron-list#2.0.12 bower_components/iron-list
├── iron-a11y-keys-behavior#2.1.0
├── iron-resizable-behavior#2.1.0
├── iron-scroll-target-behavior#2.1.0
└── polymer#2.5.0
/Users/astaniscia/WorkspacePrivato/MobileHomeAssistant/home-assistant-polymer/gulp/tasks/default.js:7
));
^
SyntaxError: Unexpected token )
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at requireDir (/Users/astaniscia/WorkspacePrivato/MobileHomeAssistant/home-assistant-polymer/node_modules/require-dir/index.js:126:33)
    at Object.<anonymous> (/Users/astaniscia/WorkspacePrivato/MobileHomeAssistant/home-assistant-polymer/gulpfile.js:3:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)


Tentative B:
Fail when I tried to build it via docker image.
I used the command docker build -t home_assistant_fe . with the effects:

....
Step 10/12 : RUN ./node_modules/.bin/bower install --allow-root
 ---> Running in eee069e792de
/bin/sh: ./node_modules/.bin/bower: not found
The command '/bin/sh -c ./node_modules/.bin/bower install --allow-root' returned a non-zero code: 127

Tentative C:
Tried to modify Docker files:

diff --git a/Dockerfile b/Dockerfile
index 073f048..070a819 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -16,10 +16,8 @@ WORKDIR /frontend
 ENV NODE_ENV production

 COPY package.json ./
-RUN yarn
-
 COPY bower.json ./
-RUN ./node_modules/.bin/bower install --allow-root
+RUN yarn

 COPY . .
 CMD [ "/bin/bash", "./script/build_frontend" ]

Results:

18:10 $ docker run  -it home_assistant_fe
[..... OK .....]
18:17 $ docker run  -it home_assistant_fe
./script/build_frontend: line 18: ./node_modules/.bin/gulp: No such file or directory

Tentative D:
Tried:

diff --git a/Dockerfile b/Dockerfile
index 073f048..91ae15e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -16,10 +16,9 @@ WORKDIR /frontend
 ENV NODE_ENV production

 COPY package.json ./
-RUN yarn
-
 COPY bower.json ./
-RUN ./node_modules/.bin/bower install --allow-root
+ENV NODE_ENV development
+RUN yarn

 COPY . .
 CMD [ "/bin/bash", "./script/build_frontend" ]

Results:

18:30 $ docker build  -t home_assistant_fe .
Sending build context to Docker daemon  2.801MB
Step 1/11 : FROM node:8.2.1-alpine
........
.......
error /frontend/node_modules/node-zopfli: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /frontend/node_modules/node-zopfli
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.6.39
node-pre-gyp info using node@8.2.1 | linux | x64
node-pre-gyp info check checked for "/frontend/node_modules/node-zopfli/lib/binding/node-v57-linux-x64/zopfli.node" (not found)
node-pre-gyp http GET https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v57-linux-x64.tar.gz
node-pre-gyp http 403 https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v57-linux-x64.tar.gz
node-pre-gyp ERR! Tried to download(403): https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v57-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for node-zopfli@1.4.0 and node@8.2.1 (node-v57 ABI, musl) (falling back to source compile with node-gyp)
node-pre-gyp http 403 status code downloading tarball https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v57-linux-x64.tar.gz
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.2.1 | linux | x64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.2.1 | linux | x64
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:483:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:397:16)
gyp ERR! stack     at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Linux 4.9.60-linuxkit-aufs
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/frontend/node_modules/node-zopfli/lib/binding/node-v57-linux-x64/zopfli.node" "--module_name=zopfli" "--module_path=/frontend/node_modules/node-zopfli/lib/binding/node-v57-linux-x64"
gyp ERR! cwd /frontend/node_modules/node-zopfli
gyp ERR! node -v v8.2.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/frontend/node_modules/node-zopfli/lib/binding/node-v57-linux-x64/zopfli.node --module_name=zopfli --module_path=/frontend/node_modules/node-zopfli/lib/binding/node-v57-linux-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/frontend/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:125:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:921:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 4.9.60-linuxkit-aufs
node-pre-gyp ERR! command "/usr/local/bin/node" "/frontend/node_modules/node-zopfli/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /frontend/node_modules/node-zopfli
node-pre-gyp ERR! node -v v8.2.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.39
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/frontend/node_modules/node-zopfli/lib/binding/node-v57-linux-x64/zopfli.node --module_name=zopfli --module_path=/frontend/node_modules/node-zopfli/lib/binding/node-v57-linux-x64' (1)
The command '/bin/sh -c yarn' returned a non-zero code: 1

Discouraged I wrote this post.

@mcspr
Copy link
Contributor

mcspr commented Feb 27, 2018

Regarding docker, inspecting last built image:

/frontend # ls /usr/local/share/.cache/yarn/v1/ | wc -l
1310
/frontend # ls -la node_modules/
total 248
drwxr-xr-x    1 root     root           170 Feb 27 17:56 .
drwxr-xr-x    1 root     root            86 Feb 27 17:56 ..
-rw-r--r--    1 root     root        251762 Feb 27 17:56 .yarn-integrity
drwxr-xr-x    1 root     root            94 Feb 27 17:56 es6-object-assign
drwxr-xr-x    1 root     root            52 Feb 27 17:56 home-assistant-js-websocket
drwxr-xr-x    1 root     root          1220 Feb 27 17:56 mdn-polyfills
drwxr-xr-x    1 root     root           212 Feb 27 17:56 preact
drwxr-xr-x    1 root     root            98 Feb 27 17:56 unfetch
/frontend #

It did the fetching, but install breaks somehow.

Odyno added a commit to Odyno/home-assistant-polymer that referenced this issue Feb 27, 2018
@mcspr
Copy link
Contributor

mcspr commented Feb 28, 2018

Looks like NODE_ENV production is the culprit. yarn will not install devDependencies with it present
After that, node-zopfli wants additional packages - some layer above yarn should also apk add make g++ python2

Image builds successfully with these changes.

@Odyno
Copy link
Contributor Author

Odyno commented Feb 28, 2018

Hello @mcspr thanks for the help!
In the end I had given up on this path... and the addition of other dependencies such as g++ and even python2 on the docker, endorsee my proposal to change the FROM container.

In addition I found out that when you install Python3 actually the python 3.6.1 is installed and not the required Python 3.6.4 .

Could you add your opinion on this PR #947 comment? I am curious to know what you think of it

Odyno added a commit to Odyno/home-assistant-polymer that referenced this issue Apr 20, 2018
Odyno added a commit to Odyno/home-assistant-polymer that referenced this issue Apr 20, 2018
Odyno added a commit to Odyno/home-assistant-polymer that referenced this issue Apr 20, 2018
balloob pushed a commit that referenced this issue Sep 10, 2018
* Review Docker management ( linked with #934 )

*  fix comment by @balloob

* Explicit remove of  package-lock.json

* moved on feature branch, merge docker scripts, added documetation

* Used alphine as requested by @balloob on #947 and followed the @mcspr comment #934

* Remove package-lock from gitignore, we don't use npm

* Update for new build instructions
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants