Docker Entrypoint script uses wrong version of Nodejs

When running the entrypoint script on
docker-compose up

which node - returns /bin/usr/node [not the one I want]

but when I attach to the container and run whichnode - I get node from .nvm folder [the one I want]

whoami and which bash return the same in both cases - root and /bin/bash respectively.

Can you advise on what can be the issue?

Here’s the dockerfile:

FROM ubuntu:22.10

ARG WWWGROUP
ARG NODE_VERSION=16

WORKDIR /var/www/api

ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#Install required libraries for php + node
RUN apt-get update
RUN apt-get install -y nginx
RUN apt-get update

#PHP
RUN apt-get install -y php8.1-cli php8.1-dev \
    php8.1-gd \
    php8.1-curl \
    php8.1-imap php8.1-mysql php8.1-mbstring \
    php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap \
    php8.1-intl php8.1-readline \
    php8.1-msgpack php8.1-igbinary php8.1-redis \
    php8.1-fpm \
    && php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer
#NODE

SHELL ["/bin/bash", "--login", "-i", "-c"]
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash -
RUN source /root/.bashrc && nvm install ${NODE_VERSION}
RUN nvm use ${NODE_VERSION}
SHELL ["/bin/bash", "--login", "-c"]

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
    && echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
    && apt-get update \
    && apt-get install -y yarn

RUN apt-get install -y git-all \
    && apt-get install sudo

#Supervisor
RUN apt-get install -y supervisor
#CLEANUP
RUN apt-get -y autoremove \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.1

RUN groupadd --force -g $WWWGROUP os
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 os

#  Add new user docker to sudo group
RUN adduser os sudo

# Ensure sudo group users are not 
# asked for a password when using 
# sudo command by ammending sudoers file
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> \
    /etc/sudoers

COPY start-container /usr/local/bin/start-container
COPY supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php/php.ini /etc/php/8.1/cli/conf.d/99-os.ini
RUN chmod +x /usr/local/bin/start-container

EXPOSE 8000

ENTRYPOINT ["start-container"]

Here’s the start-container script

#!/bin/bash

echo "Running Startup Script"
echo "Starting PHP FPM"
service php8.1-fpm start

echo "Starting Nginx"
service nginx start

echo "whoami"
whoami
nvm --version

echo "which bash and node"
which bash
which node

echo "Installing Client Dependencies"
cd /var/www/client && yarn

echo "Starting Client Dev Server"
cd /var/www/client && yarn dev

if [ ! -z "$WWWUSER" ]; then
    usermod -u $WWWUSER os
fi

if [ ! -d /.composer ]; then
    mkdir /.composer
fi

chmod -R ugo+rw /.composer

if [ $# -gt 0 ]; then
    exec gosu $WWWUSER "$@"
else
    /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
fi