Skip to content

Commit 0c12ef9

Browse files
committed
refactor: install NVM in /usr/local/nvm for global access (PHP 8.1)
Use /usr/local/nvm instead of /root/.nvm to allow all users (including www-data) to access node/npm/npx without permission issues. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent bacd537 commit 0c12ef9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

.docker/Dockerfile.php81

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,17 @@ RUN chmod uga+x /usr/local/bin/install-php-extensions && sync \
5656
&& chown -R www-data /var/www
5757

5858
# Install NVM
59-
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash \
60-
&& export NVM_DIR="/root/.nvm" \
59+
RUN export NVM_DIR="/usr/local/nvm" \
60+
&& mkdir -p "$NVM_DIR" \
61+
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash \
6162
&& . "$NVM_DIR/nvm.sh" \
6263
&& nvm install 20 \
6364
&& nvm alias default 20 \
6465
&& NODE_VERSION="$(nvm version default)" \
6566
&& ln -s "$NVM_DIR/versions/node/$NODE_VERSION/bin/node" /usr/local/bin/node \
6667
&& ln -s "$NVM_DIR/versions/node/$NODE_VERSION/bin/npm" /usr/local/bin/npm \
6768
&& ln -s "$NVM_DIR/versions/node/$NODE_VERSION/bin/npx" /usr/local/bin/npx \
68-
&& echo 'export NVM_DIR="/root/.nvm"' > /etc/profile.d/nvm.sh \
69+
&& echo 'export NVM_DIR="/usr/local/nvm"' > /etc/profile.d/nvm.sh \
6970
&& echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> /etc/profile.d/nvm.sh
7071

7172
COPY config/php/* /usr/local/etc/php/conf.d/

0 commit comments

Comments
 (0)