Wingysam / Christmas-Community

Christmas lists for families
GNU Affero General Public License v3.0
206 stars 39 forks source link

PouchDB creates empty log file that interferes with running container as non-root user #92

Open bsiddans opened 8 months ago

bsiddans commented 8 months ago

During startup pouchDB attempts to create a logfile at '/usr/src/app/log.txt'. This is outside of the location used for persistent data (/data), and the file doesn't appear to actually log anything during operation. If the log can't be created (as is the case when running the container as a user other than root) the application crashes.

For example, running the following command: docker run --detach --user 1000:1000 --name christmas-community -p 80:80 --restart always -v /persistent/data/location:/data wingysam/christmas-community

Results in the following output to the log:

[ EXPRESS ] Express server started on port 80!
[ DB EXPOSE ] DB has been exposed on port 8080
node:events:346
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open './log.txt'
Emitted 'error' event on WriteStream instance at:
    at emitErrorNT (node:internal/streams/destroy:188:8)
    at emitErrorCloseNT (node:internal/streams/destroy:153:3)
    at processTicksAndRejections (node:internal/process/task_queues:81:21) {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: './log.txt'
}

This issue only affects those running as non-root, but the fix appears to be straightforward (I'll send a PR separately).

Thanks for this project, I'm looking forward to trying it out this year.

Wingysam commented 8 months ago

Being able to run as a non-root user would be good. Thanks for the PR!