I have read the README of the nvm project, which lists the packages I need to install, although I had to modify the python2
package to python3
, since the former package was deprecated following Alpine 3.13 release, as node can run on python3
package. Here is my Dockerfile, which is meant to be part of my .devcontainer
directory to run on a Codespace:
# Pull the Alpine 3.15 Docker image
FROM alpine:3.16
# Enter the BASH shell
ENTRYPOINT [ "/bin/bash" ]
# Add packages without caching, but while upgrading Alpine
RUN apk add --no-cache -U\
curl bash ca-certificates\
openssl ncurses coreutils\
python3 make gcc g++\
libgcc linux-headers grep\
util-linux binutils findutils
RUN touch ~/.bashrc
# Install NVM and source it
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
RUN echo '\
export NVM_DIR="~/.nvm" \
[-s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" \
[[ -r $NVM_DIR/bash_completion ]] && \. $NVM_DIR/bash_completion\
' >~/.bashrc
# Run the usual setup NVM commands
RUN [ "/bin/bash", "-c", "nvm install -s --lts --latest-npm" ]
RUN [ "/bin/bash", "-c", "nvm alias default lts/*" ]
# Install NPM packages and run the dev server
RUN [ "/bin/bash", "-c", "npm i" ]
CMD [ "/bin/bash", "-c", "npm run dev" ]
Here is the line in my creation.log
file which denotes the error:
2022-09-27 14:44:57.546Z: #9 [6/8] RUN [ "/bin/bash", "-c", "nvm install -s --lts --latest-npm" ]
2022-09-27 14:44:58.134Z: #9 0.539 /bin/bash: line 1: nvm: command not found
2022-09-27 14:44:58.229Z: #9 ERROR: executor failed running [/bin/bash -c nvm install -s --lts --latest-npm]: exit code: 127
If anything else is needed, please let me know! Thanks for any help!
# Pull the Alpine 3.15 Docker image
FROM alpine:3.15
# Set the entrypoint to the `ASH` shell
ENTRYPOINT ["/bin/ash"]
# Add the needed packages without caching, but upgrading Alpine
RUN apk add --no-cache -U npm nodejs sudo git
RUN git config --global user.email [email protected]
RUN git config --global user.name BatemaDevelopment
# Add the `node` group and user, then assign the user to the group
RUN addgroup -S node && adduser -S node -G node
# Make the directory and subdirectories `/home/node/acoustic-docs/node_modules`
# and change ownership recursivly to the `node` user and group
RUN mkdir -p /home/node/acoustic-docs/node_modules && chown -R node:node /home/node/acoustic-docs
# Make the required directories for the docs
RUN mkdir -p /home/node/acoustic-docs/blog && chown -R node:node /home/node/acoustic-docs/blog
RUN mkdir -p /home/node/acoustic-docs/Buttons && chown -R node:node /home/node/acoustic-docs/Buttons
RUN mkdir -p /home/node/acoustic-docs/docs && chown -R node:node /home/node/acoustic-docs/docs
RUN mkdir -p /home/node/acoustic-docs/src && chown -R node:node /home/node/acoustic-docs/src
RUN mkdir -p /home/node/acoustic-docs/static && chown -R node:node /home/node/acoustic-docs/static
# Set the working directory to `/home/node/acoustic-docs`
WORKDIR /home/node/acoustic-docs
COPY --chown=node:node . .
CMD [ "npm", "run dev" ]