Skip to content

Commit 4bd99bc

Browse files
[Dockerfile] Refactor to prevent using sudo during build
`sudo` may lead to unpredictable behavior in some cases, and we don't really need to use `sudo` to reach what we need.
1 parent 5f9ccaa commit 4bd99bc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,17 @@ RUN wget --version
8888
# Add user "nvm" as non-root user
8989
RUN useradd -ms /bin/bash nvm
9090

91+
# Copy and set permission for nvm directory
92+
COPY . /home/nvm/.nvm/
93+
RUN chown nvm:nvm -R "home/nvm/.nvm"
94+
9195
# Set sudoer for "nvm"
9296
RUN echo 'nvm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
9397

9498
# Switch to user "nvm" from now
9599
USER nvm
96100

97101
# nvm
98-
COPY . /home/nvm/.nvm/
99-
RUN sudo chown nvm:nvm -R "$HOME/.nvm"
100102
RUN echo 'export NVM_DIR="$HOME/.nvm"' >> "$HOME/.bashrc"
101103
RUN echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> "$HOME/.bashrc"
102104
RUN echo '[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion' >> "$HOME/.bashrc"

0 commit comments

Comments
 (0)