Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Docker container crashes because of missing dependencies since ipfs@v0.51.0 #3376

Closed
elchenberg opened this issue Nov 8, 2020 · 4 comments · Fixed by #3378
Closed

Docker container crashes because of missing dependencies since ipfs@v0.51.0 #3376

elchenberg opened this issue Nov 8, 2020 · 4 comments · Fixed by #3378
Labels
kind/bug A bug in existing code (including security flaws) status/in-progress In progress

Comments

@elchenberg
Copy link

  • Version:
    • ipfs/js-ipfs:latest
    • ipfs/js-ipfs:next
    • ipfs/js-ipfs:v0.50.3-rc.24 and higher
    • ipfs/js-ipfs:v0.51.0 and higher
  • Platform:
    • Docker
      $ docker version
      Client: Docker Engine - Community
      Version:           19.03.9
      API version:       1.40
      Go version:        go1.13.10
      Git commit:        9d988398e7
      Built:             Fri May 15 00:22:47 2020
      OS/Arch:           linux/amd64
      Experimental:      false
      
      Server: Docker Engine - Community
      Engine:
      Version:          19.03.9
      API version:      1.40 (minimum version 1.12)
      Go version:       go1.13.10
      Git commit:       9d988398e7
      Built:            Fri May 15 00:28:17 2020
      OS/Arch:          linux/amd64
      Experimental:     true
      containerd:
      Version:          v1.2.13
      GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
      runc:
      Version:          1.0.0-rc10
      GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
      docker-init:
      Version:          0.18.0
      GitCommit:        fec3683
  • Subsystem:
    • ipfs-cli / electron-webrtc

Severity:

critical

Description:

Running the Docker containers fails since the introduction of ipfs-cli with it's electron-webrtc dependency.

$ docker run --rm -p 5002:5002 -it ipfs/js-ipfs:v0.51.0
Initializing IPFS daemon...
js-ipfs version: 0.1.0
System version: x64/linux
Node.js version: 12.19.0
Error: Could not start Xvfb: "Xvfb is not installed or is not in your $PATH". 
The "xvfb" package is required to run "electron-eval" on Linux. Please install it first ("sudo apt-get install xvfb").
    at /usr/lib/node_modules/ipfs/node_modules/electron-eval/lib/index.js:147:22
    at ChildProcess.onError (/usr/lib/node_modules/ipfs/node_modules/headless/index.js:70:9)
    at Object.onceWrapper (events.js:421:26)
    at ChildProcess.emit (events.js:314:20)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

It is very difficult to get Electron support in a Alpine-based image because there are no binaries built against musl libc. I have started to work on a fix (switching to a Debian-based Node container) but electron and electron-eval have a lot of dependencies (libasound2, libgconf-2-4, libgtk2.0-0, libnss3, libxss1, libxtst6, xvfb) so the container gets pretty big.

Then I tried to run the container with a small change instead and it worked, too (at the cost of losing WebRTC support, I guess):

FROM ipfs/js-ipfs:v0.51.0
RUN rm -rf /usr/lib/node_modules/ipfs/node_modules/electron-webrtc

Maybe – instead of changing the Dockerfile – it would be better to fix this bug by moving both electron-webrtc and wrtc to the optionalDependencies of ipfs-cli? (Currently electron-webrtc is in the dependencies section and wrtc in the devDependencies section.) According to the log messages they are optional anyway:

function getLibp2p ({ libp2pOptions, options, config, peerId }) {
  // Attempt to use any of the WebRTC versions available globally
  let electronWebRTC
  let wrtc
  try {
    // @ts-ignore - cant find type info
    electronWebRTC = require('electron-webrtc')()
  } catch (err) {
    log('failed to load optional electron-webrtc dependency')
  }
  try {
    wrtc = require('wrtc')
  } catch (err) {
    log('failed to load optional webrtc dependency')
  }

  if (wrtc || electronWebRTC) {
    log(`Using ${wrtc ? 'wrtc' : 'electron-webrtc'} for webrtc support`)
    set(libp2pOptions, 'config.transport.WebRTCStar.wrtc', wrtc || electronWebRTC)
    libp2pOptions.modules.transport.push(WebRTCStar)
  }

Steps to reproduce the error:

Healthy container:

docker run --rm -p 5002:5002 -it ipfs/js-ipfs:v0.50.2

Crashing container:

docker run --rm -p 5002:5002 -it ipfs/js-ipfs:v0.51.0
@elchenberg elchenberg added the need/triage Needs initial labeling and prioritization label Nov 8, 2020
@welcome
Copy link

welcome bot commented Nov 8, 2020

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@achingbrain
Copy link
Member

Thanks for bringing this up.

I think this is just a bug - electron-wrtc shouldn't be a dep at all, it's like wrtc in that it's an opt-in dep you can install if your application needs it.

WebRTC is only really intended for use in the browser since it's currently the only way in-browser nodes can be dialled - the code you've referenced is part of the daemon startup - used under node which can be dialled over TCP which is vastly preferable.

achingbrain added a commit that referenced this issue Nov 9, 2020
Remove electron-webrtc dep - as it was only being used by daemon startup
which doesn't typically run under electron.

If your application requires webrtc, see [the FAQ](https://github.com/ipfs/js-ipfs/blob/master/docs/FAQ.md#is-there-webrtc-support-for-js-ipfs-with-nodejs)
for more information.

Fixes #3376
achingbrain added a commit that referenced this issue Nov 9, 2020
Remove electron-webrtc dep - as it was only being used by daemon startup which doesn't typically run under electron.

If your application requires webrtc, see [the FAQ](https://github.com/ipfs/js-ipfs/blob/master/docs/FAQ.md#is-there-webrtc-support-for-js-ipfs-with-nodejs) for more information.

Fixes #3376

BREAKING CHANGE: electron-webrtc was accidentally bundled with ipfs, now it needs installing separately
@achingbrain achingbrain added kind/bug A bug in existing code (including security flaws) status/in-progress In progress and removed need/triage Needs initial labeling and prioritization labels Nov 9, 2020
@achingbrain
Copy link
Member

Please try this again with v0.52.0 and re-open if it's not fixed.

@elchenberg
Copy link
Author

Seems to work like a charm. Thank you very much!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug A bug in existing code (including security flaws) status/in-progress In progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants