orangecoding / fredy

:heart: Fredy - [F]ind [R]eal [E]states [D]amn Eas[y] - Fredy will constantly search for new listings on sites like Immoscout or Immowelt and send new results to you, so that you can focus on more important things in life ;)
http://www.orange-coding.net
MIT License
209 stars 54 forks source link

Crash after login (Docker): "Error: EACCES: permission denied, open '/fredy/db/.users.json.tmp'" #77

Closed lindermayr closed 1 year ago

lindermayr commented 1 year ago

Hi,

I cloned the repo with git clone and started the build with docker-compose build fredy. I get the container up and running, but when i try to login with admin/admin in the browser the container crashes with following message:

Creating network "fredy_default" with the default driver
Creating fredy ... done
Attaching to fredy
fredy    | (node:1) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
fredy    | (Use `node --trace-deprecation ...` to show where the warning was created)
fredy    | Started Fredy successfully. Ui can be accessed via http://localhost:9998
fredy    | Started API service on port 9998
fredy    | node:fs:590
fredy    |   handleErrorFromBinding(ctx);
fredy    |   ^
fredy    |
fredy    | Error: EACCES: permission denied, open '/fredy/db/.users.json.tmp'
fredy    |     at Object.openSync (node:fs:590:3)
fredy    |     at Object.writeFileSync (node:fs:2202:35)
fredy    |     at TextFileSync.write (file:///fredy/node_modules/lowdb/lib/adapters/TextFileSync.js:36:12)
fredy    |     at JSONFileSync.write (file:///fredy/node_modules/lowdb/lib/adapters/JSONFileSync.js:29:66)
fredy    |     at LowdashAdapter.write (file:///fredy/node_modules/lowdb/lib/LowSync.js:28:26)
fredy    |     at Module.setLastLoginToNow (file:///fredy/lib/services/storage/userStorage.js:75:6)
fredy    |     at file:///fredy/lib/api/routes/loginRoute.js:28:17
fredy    |     at next (/fredy/node_modules/0http/lib/next.js:35:14)
fredy    |     at Trouter.router.lookup (/fredy/node_modules/0http/lib/router/sequential.js:93:14)
fredy    |     at Object.service.lookup (/fredy/node_modules/restana/libs/request-router.js:75:49)
fredy    |     at next (/fredy/node_modules/0http/lib/next.js:33:25)
fredy    |     at step (/fredy/node_modules/0http/lib/next.js:15:14)
fredy    |     at serveStatic (/fredy/node_modules/serve-static/index.js:75:16)
fredy    |     at next (/fredy/node_modules/0http/lib/next.js:35:14)
fredy    |     at step (/fredy/node_modules/0http/lib/next.js:15:14)
fredy    |     at _cookieSession (/fredy/node_modules/cookie-session/index.js:135:5) {
fredy    |   errno: -13,
fredy    |   syscall: 'open',
fredy    |   code: 'EACCES',
fredy    |   path: '/fredy/db/.users.json.tmp'
fredy    | }
fredy exited with code 1

I tried this on 3 different virtual Hosts running Ubuntu 22.10, one ARM64 machine and two x64 machines.

TobiasHeinen commented 1 year ago

I had the same issue. The db directory was limited to root (unlike config, for some reason). Using sudo chown [your_user] db and restarting the container worked for me.

lindermayr commented 1 year ago

I had the same issue. The db directory was limited to root (unlike config, for some reason). Using sudo chown [your_user] db and restarting the container worked for me.

Oh, thanks for the help. I also had to change the permissions for the files in conf to save the settings.