Skip to content

Commit f5fce7d

Browse files
committed
Permissions for global NPM packages
1 parent d0b634b commit f5fce7d

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/javascript-node/Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ FROM node:${VARIANT}
44

55
ARG USERNAME=node
66

7-
# Install eslint
8-
RUN su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
7+
RUN \
8+
# Configure global npm install location, use group to adapt to UID/GID changes
9+
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
10+
&& usermod -a -G npm ${USERNAME} \
11+
&& umask 0002 \
12+
&& mkdir -p ${NPM_GLOBAL} \
13+
&& touch /usr/local/etc/npmrc \
14+
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
15+
&& chmod g+s ${NPM_GLOBAL} \
16+
&& npm config -g set prefix ${NPM_GLOBAL} \
17+
&& sudo -u ${USERNAME} npm config -g set prefix ${NPM_GLOBAL} \
18+
# Install eslint
19+
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
920
&& npm cache clean --force > /dev/null 2>&1
1021

1122
# [Optional] Uncomment this section to install additional OS packages.

0 commit comments

Comments
 (0)