Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Docker instructions #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

dagelf
Copy link
Contributor

@dagelf dagelf commented Nov 12, 2024

#6

@claudio-silva
Copy link
Owner

Hi, thanks for your contribution :-)
This is a very useful addition for those how don't have a node version manager (like nvm) and just want to get things going ASAP.
Unfortunately, I was unable to run it successfully, as it throws an error on my Macbook, because of the arm64 architecture, and some incompatibility with a package.

> vite --host

/app/node_modules/rollup/dist/native.js:59
		throw new Error(
		      ^

Error: Cannot find module @rollup/rollup-linux-arm64-gnu. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.

I'd like to merge this, but I'll have to test it with a x86 machine first and/or manage to get it to run on a ARM Mac.

@dagelf
Copy link
Contributor Author

dagelf commented Nov 12, 2024

It might be because the node_modules on your host is a bit different from inside the container... see if it works if you rm -rf node_modules or if you clone into a new directory?

@dagelf
Copy link
Contributor Author

dagelf commented Nov 12, 2024

But this might be the best solution still:

add -v /app/node_modules to the docker command, that should override that directory - just add it after the other -v

Technically, I think if you ran node:19 or node:20 or node:21... just change that bit in the docker command - likely your host has a different version of node. Think it's just conflict between container and host because we're using the directory on the host directly.

@claudio-silva
Copy link
Owner

Yes, I guess that was the reason.
Unfortunately, I still can't run it, unless I remove the -u argument, because it causes permission problems when using npm:

npm error code EACCES
npm error syscall mkdir
npm error path /app/node_modules/@alloc
npm error errno -13
npm error Error: EACCES: permission denied, mkdir '/app/node_modules/@alloc'
...

And I did try it with a newly cloned project.
The problem when not setting the user to the current user is that the actual user may have trouble editing some files in the project.

@dagelf
Copy link
Contributor Author

dagelf commented Nov 12, 2024

Hang on, that directory is underneath the node_modules - did you also add the -v /app/node_modules ? Might be that docker's ability to overlay subpaths varies between implementations...

@claudio-silva
Copy link
Owner

I did add the -v /app/node_modes argument.
If I don't add it, it gets even weirder.

npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, open '/app/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs'
(and lots of other warnings like this)
npm warn cleanup Failed to remove some directories [
npm warn cleanup   [
npm warn cleanup     '/app/node_modules/@types/react',
npm warn cleanup     [Error: ENOTEMPTY: directory not empty, rmdir '/app/node_modules/@types/react'] {
npm warn cleanup       errno: -39,
npm warn cleanup       code: 'ENOTEMPTY',
npm warn cleanup       syscall: 'rmdir',
npm warn cleanup       path: '/app/node_modules/@types/react'
npm warn cleanup     }
npm warn cleanup   ],
(and much more like this)
npm warn tar TAR_ENTRY_ERROR ENOENT: no such file or directory, lstat '/app/node_modules/@babel/helpers/lib/helpers'
(and even more like this)

I'll see if I can find some time do delve into this, as I would like to understand what's going on here.
Anyway, it does work if we don't change the docker user.

@dagelf
Copy link
Contributor Author

dagelf commented Nov 12, 2024

Okay, I see that not all users have permission to volumes inside docker...

I guess it's fine to run without the -u then. Only potential issue then is if the app tries to write anything it will be written as root and then the user on the host won't be able to change it then.

I'm racking my brain trying to think of a way to run it with this convenient oneliner in a portable way, without having to create an actual container that needs to be managed...

@dagelf
Copy link
Contributor Author

dagelf commented Nov 12, 2024

So, turns out the only way is to run the container without -u, and then add the user, change permissions, and then run node as that user. There goes my 3-command oneliner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants