goldbergyoni / goldbergyoni/nodebestpractices

Need clarifications to full multi-stage Dockerfile example

Open
#1,146 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Dockerfile
Stars
106k
Forks
10.7k
PR merge metrics
No merged PRs in 30d

Description

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: https://github.com/moby/moby/issues/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
...
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Open sections/docker/multi_stage_builds.md around lines 79-121 and review the linked Docker WORKDIR issue. Reproduce the example with classic Docker build, then update the paragraph or Dockerfile example so the documented setup avoids the reported permission error; done means the example works without the EACCES failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
dockerfile, node.js
Domain
devops, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.