Osedea / nodock

Docker Compose for Node projects with Node, MySQL, Redis, MongoDB, NGINX, Apache2, Memcached, Certbot and RabbitMQ images
http://nodock.io
MIT License
762 stars 189 forks source link

Node service exits immediately after fresh build following instructions on home page #93

Closed zachariahtimothy closed 5 years ago

zachariahtimothy commented 6 years ago

I followed the instructions on the home page to try this repo out:

git clone https://github.com/Osedea/nodock.git
cp nodock/_examples/nginx/* . 
cd nodock/ && docker-compose up -d node nginx

The nginx node comes up fine but the node node fails immediately with the following error

    at Function.Module._resolveFilename (module.js:557:15)
    at Function.Module._load (module.js:484:25)
    at Function.Module.runMain (module.js:703:10)
    at startup (bootstrap_node.js:193:16)
    at bootstrap_node.js:665:3

Am I missing or not understanding something here?

philtrep commented 6 years ago

@zachariahtimothy thanks for using NoDock and creating an issue, try running docker-compose down && docker-compose up --build -d node nginx from the NoDock folder.

I have not been able to replicate the issue so I'll need a few info from you:

  1. Docker/Docker-Compose versions
  2. Host OS + Version

Was there anything in the project folder before you cloned nodock?

zachariahtimothy commented 6 years ago

Thank you for the reply @philtrep , I think this approach is AMAZING and am really excited to get it working. Using the method you describe, I now get the following errors

npm WARN using --force I sure hope you know what you are doing.
npm WARN checkPermissions Missing write access to /opt/app
npm WARN example-simple-web-node-docker@1.0.0 No repository field.

npm ERR! path /opt/app/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/opt/app/node_modules'
npm ERR!  { Error: EACCES: permission denied, mkdir '/opt/app/node_modules'
npm ERR!   cause:
npm ERR!    { Error: EACCES: permission denied, mkdir '/opt/app/node_modules'
npm ERR!      errno: -13,
npm ERR!      code: 'EACCES',
npm ERR!      syscall: 'mkdir',
npm ERR!      path: '/opt/app/node_modules' },
npm ERR!   stack: 'Error: EACCES: permission denied, mkdir \'/opt/app/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/opt/app/node_modules',
npm ERR!   parent: 'example-simple-web-node-docker' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/www-app/.npm/_logs/2018-02-27T17_49_23_212Z-debug.log
module.js:559
    throw err;
    ^

Error: Cannot find module 'express'
    at Function.Module._resolveFilename (module.js:557:15)
    at Function.Module._load (module.js:484:25)
    at Module.require (module.js:606:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/opt/app/index.js:1:77)
    at Module._compile (module.js:662:30)
    at Object.Module._extensions..js (module.js:673:10)
    at Module.load (module.js:575:32)
    at tryModuleLoad (module.js:515:12)
    at Function.Module._load (module.js:507:3)

System info:

  1. Docker version 18.02.0-ce, build fc4de44 / docker-compose version 1.19.0, build 9e633ef
  2. MacOS V 10.13.3
philtrep commented 6 years ago

@zachariahtimothy Okay I see, the problem is that for some reason the user installing the javascript dependencies (www-app) does not have the permissions required to create the node_modules folder. It's odd since there is a line in the node Dockerfile that gives full permissions to the executing user on the mounted app folder 🤔

It's not a long-term fix but to allow you to use NoDock for the moment, from your host machine in your project folder run:

mkdir node_modules
chmod -R 777 node_modules
cd nodock/
docker-compose down && docker-compose up --build -d node nginx

If that doesn't work, try purging everything. WARNING: this will destroy every container/image/volume on your machine

docker stop $(docker ps -qa); docker rm -f $(docker ps -qa); docker rmi $(docker images -q); docker volume rm $(docker volume ls -q)

And running.

docker-compose up --build -d node nginx

Let me know if this helps!

philtrep commented 6 years ago

@zachariahtimothy Any success? 😄

imnotteixeira commented 5 years ago

Hi, I've been having the exact same problem, and I can confirm that the hotfix does work, however, it is not ideal because everytime I clone the repo, that must be done, as the permissions are not correct. By inspecting the Dockerfile and scripts, as well as the logs, I found out that the www-app user has no write access to /opt/app image

The line that you referenced chmod 777 /home/www-app -R gives permissions to the /home/www-app folder as far as I know, however it does not solve the problem as there are no permissions to /opt/app folder. If you could help on this I'd be grateful. :+1:

philtrep commented 5 years ago

@imnotteixeira I'll take a look at a permanent fix tomorrow

MJGTwo commented 5 years ago

@philtrep I was able to reproduce @zachariahtimothy 's error and successfully used your patch from Feb to fix it. Do keep us posted about solution.

philtrep commented 5 years ago

@imnotteixeira @MJGTwo sorry guys, work has been a lil crazy as of late and my open source contributions have suffered.

I am unable to replicate the error but I'll bet that #109 fixes it.

Let me know how it goes 😄

Realetive commented 5 years ago

Has similar error. Fixed with move https://github.com/Osedea/nodock/pull/109/files#diff-fd862f8df18ad438a72182fe51f139d1R19 on 13 line (before if [[ $YARN = true ]]; then).