-
Notifications
You must be signed in to change notification settings - Fork 0
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
Docker changes #231
base: develop
Are you sure you want to change the base?
Docker changes #231
Conversation
Fix "When using COPY with more than one source file, the destination must be a directory and end with a / or a \"
https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user Fixes errors with `npm install` in building the container: [!] (plugin commonjs--resolver) Error: EACCES: permission denied, stat '/root/.node_modules/vre' Error: EACCES: permission denied, stat '/root/.node_modules/vre'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried building and running the frontend via Docker with
docker compose up frontend
, but this failed:frontend-1 | bundles vre/main.js → vre/bundle.js...
frontend-1 | [!] (plugin commonjs--resolver) Error: EACCES: permission denied, stat '/root/.node_modules/vre'
frontend-1 | Error: EACCES: permission denied, stat '/root/.node_modules/vre'Running the frontend container as the unprivileged
node
user fixes this.
I am a bit surprised because I don't recall running into such problems myself. But the fix seems reasonable and unproblematic.
As an aside, is there a benefit to storing the node_modules as a volume rather than just having it in the built container?
Yes, it speeds up the build and reduces the need for rebuilds, because the node_modules don't end up creating their own (continuously evolving) image layer.
@@ -1,7 +1,7 @@ | |||
FROM python:3.9-bullseye | |||
|
|||
WORKDIR /usr/src/app/backend | |||
COPY requirements.txt requirements-test.txt . | |||
COPY requirements.txt requirements-test.txt ./ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this slash actually matter or is it just a spurious change by your autoformatter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was intentional, to resolve a linting issue (When using COPY with more than one source file, the destination must be a directory and end with a / or a \
) provided via vscode-docker
.
I wondered about the |
Isn't that just how Docker volumes are supposed to work? You declare a virtual disk that Docker manages behind your back. It is the same for the database and the python cache. Maybe I'm misunderstanding your question? |
I don't mean how Docker manages its internals, but that here the local git repository gets an (empty) directory |
Strange. I get that empty directory in the host system as well, but it is owned by me, not by root. Did you run |
No, but by default Docker runs as root. I guess you are running Docker rootless mode? |
Not consciously? I just installed Docker Desktop and went with it, without configuring anything. |
I tried building and running the frontend via Docker with
docker compose up frontend
, but this failed:Running the frontend container as the unprivileged
node
user fixes this.As an aside, is there a benefit to storing the node_modules as a volume rather than just having it in the built container?