schlagmichdoch / PairDrop

PairDrop: Transfer Files Cross-Platform. No Setup, No Signup.
https://pairdrop.net
GNU General Public License v3.0
4.68k stars 261 forks source link

[Bug] errno -13 on Alpine/Docker #160

Closed walteroa2023 closed 1 year ago

walteroa2023 commented 1 year ago

Describe the bug permission error as follows:

npm ERR! code EACCES npm ERR! syscall open npm ERR! path /home/node/app/package-lock.json npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, open '/home/node/app/package-lock.json' npm ERR! [Error: EACCES: permission denied, open '/home/node/app/package-lock.json'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'open', npm ERR! path: '/home/node/app/package-lock.json' npm ERR! }

To Reproduce docker-compose up -d --force-recreate

Expected behavior no error messages

Desktop (please complete the following information):

Bug occurs on official PairDrop instance https://pairdrop.net/ No

Bug occurs on self-hosted PairDrop instance No

Self-Hosted Setup Deployment: docker-compose Version: v2.17.3 `version: "3" services: node: image: "node:lts-alpine" user: "node" working_dir: /home/node/app volumes:

schlagmichdoch commented 1 year ago

I cannot reproduce your error but it seems as if the executing user does not have the proper permissions to create the docker image. Try running docker-compose up -d --force-recreate as sudo

walteroa2023 commented 1 year ago

Thx a lot for your fast answer @schlagmichdoch... user UID=1000 is part of sudoers group and docker groups with right permissions, all other containers i have (+20) are running ok... so? any suggestions or log to see?

schlagmichdoch commented 1 year ago

Does this also happen when you use the pre built docker from linuxserver or ghcr? https://github.com/schlagmichdoch/PairDrop/blob/master/docs/host-your-own.md#deployment-with-docker-compose


What were the steps you took for it to work?

  1. git clone this repo
  2. edit docker-compose.yml
  3. run docker-compose up -d --force-recreate

Anything else?


What's the output of running docker compose run node ls -la after step 3?

walteroa2023 commented 1 year ago

I did use docker run, just to make sure nothing went wrong... (instead of using docker-compose file) docker run -d --restart=unless-stopped --name=pairdrop -p 127.0.0.1:9100:3000 ghcr.io/schlagmichdoch/pairdrop npm run start:prod

container goes running, but no answer for mapped port (in my case 9100/tcp)

this is the output for this command: docker compose run node ls -la

Output: drwxr-xr-x 8 root root 4096 Sep 22 20:29 . drwxr-sr-x 1 node node 4096 Sep 22 21:10 .. -rw-r--r-- 1 root root 32 Sep 22 20:29 .dockerignore drwxr-xr-x 8 root root 4096 Sep 22 20:29 .git drwxr-xr-x 4 root root 4096 Sep 22 20:29 .github -rw-r--r-- 1 root root 58 Sep 22 20:29 .gitignore -rw-r--r-- 1 root root 19 Sep 22 20:29 .npmrc -rw-r--r-- 1 root root 1744 Sep 22 20:29 CONTRIBUTING.md -rw-r--r-- 1 root root 247 Sep 22 20:29 Dockerfile -rw-r--r-- 1 root root 35149 Sep 22 20:29 LICENSE -rw-r--r-- 1 root root 6895 Sep 22 20:29 README.md -rw-r--r-- 1 root root 528 Sep 22 20:29 docker-compose-coturn.yml -rw-r--r-- 1 root root 257 Sep 22 20:47 docker-compose.yml drwxr-xr-x 2 root root 4096 Sep 22 20:29 docs -rw-r--r-- 1 root root 25751 Sep 22 20:29 index.js -rw-r--r-- 1 root root 42970 Sep 22 20:29 package-lock.json -rw-r--r-- 1 root root 455 Sep 22 20:29 package.json drwxr-xr-x 2 root root 4096 Sep 22 20:29 pairdrop-cli drwxr-xr-x 6 root root 4096 Sep 22 20:29 public drwxr-xr-x 6 root root 4096 Sep 22 20:29 public_included_ws_fallback -rw-r--r-- 1 root root 230 Sep 22 20:29 rtc_config_example.json -rw-r--r-- 1 root root 752 Sep 22 20:29 turnserver_example.conf

So, any clue??

walteroa2023 commented 1 year ago

additionally, from portainer logs: [it ran with docker run, not docker-compose file]

pairdrop@1.8.1 start:prod node index.js --rate-limit --auto-restart PairDrop is running on port 3000

======================================================== Anyway, on host server, mapped at 9100/tcp, nothing happens

BTW: i have another container (ntopNG) running as host mode in port 3000/tcp.

walteroa2023 commented 1 year ago

Does this also happen when you use the pre built docker from linuxserver or ghcr?

i have used the ghcr image: ghcr.io/schlagmichdoch/pairdrop

walteroa2023 commented 1 year ago

Then, when i run my docker-compose file, the logs from docker compose shows:

npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, open '/home/node/app/package-lock.json' npm ERR! [Error: EACCES: permission denied, open '/home/node/app/package-lock.json'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'open', npm ERR! path: '/home/node/app/package-lock.json' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in: /home/node/.npm/_logs/2023-09-22T21_09_53_460Z-debug-0.log

as a conclusion:

walteroa2023 commented 1 year ago

updated docker compose file: `version: "3" services: node: image: "ghcr.io/schlagmichdoch/pairdrop:latest" user: "node" working_dir: /home/node/app volumes:

schlagmichdoch commented 1 year ago

It is really hard to debug your case the way you structure your posts. Please try to structure your information and use multi-line code blocks and syntax highlighting whenever applicable. These make debugging much easier!

Also you mixed the outputs of all possible ways to get a docker image up and running.

After testing all possibilities I could finally reproduce your error. The problem is your mounting of local directories to your docker and reinstalling node packages with root even though they are part of the docker image already.


Let's stick with the docker-compose file using ghcr.

Your current docker-compose.yml is:

version: "3"
services:
  node:
    image: "ghcr.io/schlagmichdoch/pairdrop:latest"
    user: "node"
    working_dir: /home/node/app
    volumes:
      - ./app:/home/node/app
    command: ash -c "npm i && npm run start:prod"
    restart: unless-stopped
    ports:
      - "9100:3000"

Why are you mounting a local path to your container and try to reinstall node packages if you use the ghcr.io image? Please stick to the documentation for the correct syntax when using docker-compose files and try not to mix everything up.

Also, the docker-compose files that you find in this repository only work if you want to build the image yourself (e.g. for devs). It seems that you simply want to run the docker image, so I would recommend sticking to the ghcr.io or linuxserver.io image and not bothering with building it yourself

Retry by reducing the compose file to the bare minimum:

version: "3"
services:
  pairdrop:
    image: "ghcr.io/schlagmichdoch/pairdrop:latest"
    command: npm run start
    ports:
      - "9100:3000"

Then run docker compose up or sudo docker compose up depending on your system.

This should give you a running PairDrop instance at port 9100 and log directly to your console.

If that works you can stop it with CMD + C and change the YAML file to the following for production:

version: "3"
services:
  node:
    image: "ghcr.io/schlagmichdoch/pairdrop:latest"
    user: "node"
    command: npm run start:prod
    container_name: pairdrop
    restart: unless-stopped
    environment:
      - NODE_ENV=production
      - PUID=1000 # UID to run the application as
      - PGID=1000 # GID to run the application as
      - WS_FALLBACK=false # Set to true to enable websocket fallback if the peer to peer WebRTC connection is not available to the client.
      - RATE_LIMIT=false # Set to true to limit clients to 1000 requests per 5 min.
      - TZ=Etc/UTC # Time Zone
    ports:
      - "9100:3000"
walteroa2023 commented 1 year ago
version: "3"
services:
  node:
    image: "ghcr.io/schlagmichdoch/pairdrop:latest"
    user: "node"
    command: npm run start:prod
    container_name: pairdrop
    restart: unless-stopped
    environment:
      - NODE_ENV=production
      - PUID=1000 # UID to run the application as
      - PGID=1000 # GID to run the application as
      - WS_FALLBACK=false # Set to true to enable websocket fallback if the peer to peer WebRTC connection is not available to the client.
      - RATE_LIMIT=false # Set to true to limit clients to 1000 requests per 5 min.
      - TZ=Etc/UTC # Time Zone
    ports:
      - "9100:3000"

Thx so much for the advise and as "always learning" path, code block syntax tip helps a lot!! and Thx so much too, for having the time to reproduce the issue, . As you suggest, the last compose for production works like a charm... :)

My next step is to have public thru reverse proxy (npm), should I deploy the turn server or, is not necessary?

schlagmichdoch commented 1 year ago

Glad I could help!

You have to host your own TURN server to enable transfers between different networks. Otherwise, it will only work to discover devices on the same network.

To host your own TURN server you can follow this guide: https://gabrieltanner.org/blog/turn-server/ Alternatively, use a free, pre-configured TURN server like OpenRelay.