Docker: Fix etherpad user home dir for npm install#3674
Docker: Fix etherpad user home dir for npm install#3674m3adow wants to merge 1 commit intoether:developfrom m3adow:patch-1
npm install#3674Conversation
I tried using sqlite with etherpad-lite, but `npm install sqlite3` can't run because npm can't create its .npm directory as it's trying `mkdir $HOME/.npm` which currently evaluates to `/.npm` ``` etherpad@f717076dc742:/opt/etherpad-lite$ npm install sqlite3 npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /.npm npm ERR! errno -13 npm ERR! npm ERR! Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which has since been addressed. npm ERR! npm ERR! To permanently fix this problem, please run: npm ERR! sudo chown -R 65534:65534 "/.npm" ``` This small change properly configures the home directory to `/opt/etherpad-lite`.
npm installnpm install
|
Thanks for finding the bug, @m3adow. Isn't there a way to explicitly tell npm to put its I'll have a look at the npm documentation in the meantime. |
|
Looking closer, I see that eea99fe seemingly set |
|
For my workaround build I added There is a npm command to set the cache: From my point of view it's either change the home dir of the etherpad user to /opt/etherpad-lite like in this PR or create a specific home directory where the user has write permissions in, e.g. /home/etherpad. After some thinking I prefer the second method, as I don't think npm related stuff should be located in the /opt/etherpad-lite folder which may be volumized, especially not a cache. |
Nope, that was an oversight. Thanks @m3adow for finding this! |
|
What about replacing: With a Maybe this could solve both problems in a non-surprising way. |
|
A call to useradd (and groupadd) might be equivalent indeed. I'd just set an explicit However, changing the home user to If I may ask, @m3adow , what is your use case for installing a npm package on a built container, versus something like this? |
Nice! I'd like that.
I am sure it works, my itch is then we would violate FHS (not that anyone cares, nowadays, but...).
I had the same curiosity, but then decided to back off: if a user wants to do something unexpected, let him be free and let's try to be as robust as possible :) Do you think useradd/groupadd with explicit uid/gid be ok for fixing this problem? |
Twofold:
That would've been my first proposal, but I assumed the user and group were created this way to minimize binary use, so it's easier to port the image to slim images like alpine in the future. |
|
We have a double problem.
Thus, if we want to enable installing further modules, here's my proposal:
The most straightforward way to 2. might be to create Here's my stab at it: #3676 Note that I have found out that |
Let's go with that.
Don't worry: we released beta1 for ironing out these problems. |
|
Well, I think #3676 deprectates my CR. |
|
@m3adow sorry for taking over, that was not my initial intention. I ended up writing a possible solution while investigating the issue. Thank you for finding and reporting the error I have introduced to the codebase! |
|
Queued #3676. Thanks @m3adow for finding the issue! Aside: due to our conversation, and various considerations I was doing recently, I've opened #3675 to bring the database access layer into the code base. The work on that will take place after 1.8.0 is finally released, but I would like to start the discussion in the meantime. |
I tried using sqlite with etherpad-lite, but
npm install sqlite3can't run because npm can't create its .npm directory as it's tryingmkdir $HOME/.npmwhich currently evaluates to/.npmThis small change properly configures the home directory to
/opt/etherpad-lite.