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

Need clarifications to full multi-stage Dockerfile example #1146

Open
lodinis opened this issue Feb 1, 2022 · 1 comment
Open

Need clarifications to full multi-stage Dockerfile example #1146

lodinis opened this issue Feb 1, 2022 · 1 comment

Comments

@lodinis
Copy link

lodinis commented Feb 1, 2022

https://github.com/lodinis/nodebestpractices/blob/b8bd67ec16734d60ac208b7309bde995abc097e5/sections/docker/multi_stage_builds.md?plain=1#L79-L121

It seems some permission issues with WORKDIR when using classic (non-buildkit) docker build.
WORKDIR directive creates a new folder with root ownership what causes permission errors on node modules installation:

error Could not write file "/home/node/app/yarn-error.log": "EACCES: permission denied, open '/home/node/app/yarn-error.log'"
error An unexpected error occurred: "EACCES: permission denied, mkdir '/home/node/app/node_modules'".

Detailed WORKDIR permission issue here: moby/moby#36677

I think it's necessary to specify in this paragraph always enabling BuildKit for this multistage Dockerfile build or change Dockerfile example code with:

...
USER node

RUN mkdir -p /home/node/app

WORKDIR /home/node/app
...
@lodinis lodinis changed the title Need clarifications to full multi-stage Dockerfile example. Need clarifications to full multi-stage Dockerfile example Feb 1, 2022
@goldbergyoni
Copy link
Owner

@lodinis Welcome 🌻. Great insight. Would you mind PRing this small and important clarification?

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

No branches or pull requests

2 participants