psi-4ward / psitransfer

Simple open source self-hosted file sharing solution.
BSD 2-Clause "Simplified" License
1.45k stars 211 forks source link

Issue with PsiTransfer in Portainer on Synology NAS #270

Closed Roebie closed 1 year ago

Roebie commented 1 year ago

I have installed PsiTransfer by creating a stack in my Portainer running on my Synology NAS. With a little help from composerize I have created this yaml for PsiTransfer (though I've hidden some values here for obvious reasons):

version: "3"
services:
  psitransfer:
    container_name: psitransfer
    restart: no
    image: psitrax/psitransfer
    ports:
      - '****:3000'
    volumes:
      - /volume2/docker-psitransfer:/data
    environment:
      PSITRANSFER_ADMIN_PASS: "******"
      PSITRANSFER_UPLOAD_PASS: "******"
      PSITRANSFER_REQUIRE_BUCKET_PASSWORD: "true"
      PSITRANSFER_DEFAULT_RETENTION: "one-time"
      PSITRANSFER_MAX_AGE: "604800"
      PSITRANSFER_DEFAULT_LANGUAGE: "nl"

Basically, this works. The stack starts. But almost immediately it also stops with this error message:

/app/lib/db.js:50
      throw e;
      ^
Error: db initialization failed with error EACCES: permission denied, scandir '/data'
    at Object.readdirSync (node:fs:1451:3)
    at DB._sync (/app/lib/db.js:61:9)
    at DB.init (/app/lib/db.js:46:12)
    at Object.<anonymous> (/app/lib/endpoints.js:33:4)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18) {
  errno: -13,
  syscall: 'scandir',
  code: 'EACCES',
  path: '/data'
}
Node.js v18.12.1

I think this is because PsiTransfer can't read from (or write to) my folder /volume2/docker-psitransfer because I have no equivalent for this instruction in your installation instructions:

sudo chown -R 1000 $PWD/data

I have given full access rights on this folder to a user docker-psitransfer (UID 1041, GID 65536) but I can't seem to find a way to tell PsiTransfer that. Even if I knew how to issue the chown command from within Portainer, it would be useless. There is no user with UID 1000 on a Synology NAS. From what I understand it is even simply impossible to have a user with a UID less than 1024 by design.

How can I solve this? Thanks in advance, beer afterwards.

psi-4ward commented 1 year ago

https://docs.docker.com/compose/compose-file/05-services/#user

let psitransfer run with the desired UID by setting services.psitransfer.user

Roebie commented 1 year ago

Thanks! This works perfectly. And I learned something new.