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

openBrowser() causes docker-compose set ups to fail because of spawn EACCESS #710

Closed
aeneasr opened this issue Sep 23, 2016 · 4 comments · Fixed by #711
Closed

openBrowser() causes docker-compose set ups to fail because of spawn EACCESS #710

aeneasr opened this issue Sep 23, 2016 · 4 comments · Fixed by #711

Comments

@aeneasr
Copy link

aeneasr commented Sep 23, 2016

Description

I am running npm start inside of a docker container that is orchestrated using docker-compose, which isn't working. Running the image with pure docker however works.

This issue was already tackled in #306 but rejected.

Expected behavior

The image should boot up normally.

Actual behavior

I get this exception:

?[33mdeveloper-ui_1  |?[0m > developer-ui@0.1.0 start /usr/src/app
?[33mdeveloper-ui_1  |?[0m > react-scripts start
?[33mdeveloper-ui_1  |?[0m
?[33mdeveloper-ui_1  |?[0m ?cStarting the development server...
?[33mdeveloper-ui_1  |?[0m
?[33mdeveloper-ui_1  |?[0m internal/child_process.js:302
?[33mdeveloper-ui_1  |?[0m     throw errnoException(err, 'spawn');
?[33mdeveloper-ui_1  |?[0m     ^
?[33mdeveloper-ui_1  |?[0m
?[33mdeveloper-ui_1  |?[0m Error: spawn EACCES
?[33mdeveloper-ui_1  |?[0m     at exports._errnoException (util.js:1007:11)
?[33mdeveloper-ui_1  |?[0m     at ChildProcess.spawn (internal/child_process.js:302:11)
?[33mdeveloper-ui_1  |?[0m     at Object.exports.spawn (child_process.js:383:9)
?[33mdeveloper-ui_1  |?[0m     at module.exports (/usr/src/app/node_modules/react-scripts/node_modules/opn/index.js:75:24)
?[33mdeveloper-ui_1  |?[0m     at openBrowser (/usr/src/app/node_modules/react-scripts/scripts/start.js:173:3)
?[33mdeveloper-ui_1  |?[0m     at Server.devServer.listen (/usr/src/app/node_modules/react-scripts/scripts/start.js:308:5)
?[33mdeveloper-ui_1  |?[0m     at Server.g (events.js:286:16)
?[33mdeveloper-ui_1  |?[0m     at emitNone (events.js:86:13)
?[33mdeveloper-ui_1  |?[0m     at Server.emit (events.js:185:7)
?[33mdeveloper-ui_1  |?[0m     at emitListeningNT (net.js:1279:10)
?[33mdeveloper-ui_1  |?[0m     at _combinedTickCallback (internal/process/next_tick.js:71:11)
?[33mdeveloper-ui_1  |?[0m     at process._tickCallback (internal/process/next_tick.js:98:9)
?[33mdeveloper-ui_1  |?[0m
?[33mdeveloper-ui_1  |?[0m npm info lifecycle developer-ui@0.1.0~start: Failed to exec start script

Environment

Dockerfile

FROM node:6.2

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY . /usr/src/app
RUN npm install --silent; exit 0

# fix for https://github.com/facebookincubator/create-react-app/issues/508
RUN chmod a+x /usr/src/app/node_modules/.bin/react-scripts

ENTRYPOINT npm start

EXPOSE 3000

docker-compose.yml

version: '2'

services:
  developer-ui:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "5001:3000"

Then, specify:

  1. Operating system: Windows (host)
  2. Browser and version: not relevant
$ docker-compose -v
docker-compose version 1.8.0, build d988a55
$ docker -v
Docker version 1.12.0, build 8eab29e

Reproducible Demo

Here: https://github.com/arekkas/cra-docker-bug

Solution

Have a setting that disables browser spawn. It's annoying anyways when working with different browers (I use ff for browsing and chrome for dev) ;)

@gaearon
Copy link
Contributor

gaearon commented Sep 23, 2016

What is the use case for running npm start inside Docker? (I don't know anything about Docker. :-)

@aeneasr
Copy link
Author

aeneasr commented Sep 23, 2016

I run a lot of projects, most of them with different node requirements. It is really convenient to just run this stuff in docker. Think of it as vagrant without the slowness.

@aeneasr
Copy link
Author

aeneasr commented Sep 23, 2016

I think there are several cases that justify disabling the browser spawn. One of them being Electron, another being docker-compose, another being missing privileges for spawning processes (e.g. restricted user), another one being that it's cool to have it for demonstration but it get's quickly annoying when developing. I restore sessions on every boot and get multiple tabs of my react app because I forgot to close the old tabs. It's annoying because I hate FF dev tools and every time I run npm start I have to close the tab in ff and open it in chrome.

I think it's ok-ish to not support all of the use cases (docker, electron) with dev power, but disabling browser spawn is a very simple thing to do, that will not only resolve those issues, it will also save me and others a lot of anger when dealing with create-react-app. I can speak for myself because I had browser spawn in my projects too until the community got me to rethink and give them something to disable it. Please reconsider your position on this.

@aeneasr
Copy link
Author

aeneasr commented Sep 23, 2016

Or at least make it in such a way that openBrowser doesn't kill the npm start process when failing.

aeneasr pushed a commit to aeneasr/create-react-app that referenced this issue Sep 23, 2016
…EACCESS - closes facebook#710

Signed-off-by: Aeneas Rekkas (arekkas) <aeneas@ory.am>
gaearon pushed a commit that referenced this issue Sep 23, 2016
…EACCESS (#711)

* openBrowser() causes docker-compose set ups to fail because of spawn EACCESS - closes #710

Signed-off-by: Aeneas Rekkas (arekkas) <aeneas@ory.am>

* Ignore errors
feiqitian pushed a commit to feiqitian/create-react-app that referenced this issue Oct 25, 2016
…EACCESS (facebook#711)

* openBrowser() causes docker-compose set ups to fail because of spawn EACCESS - closes facebook#710

Signed-off-by: Aeneas Rekkas (arekkas) <aeneas@ory.am>

* Ignore errors
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants