Skip to content

Instantly share code, notes, and snippets.

@prosenjit-manna
Last active February 13, 2025 15:13
Show Gist options
  • Save prosenjit-manna/974309d28f43fbe0af3b9a849428b5b0 to your computer and use it in GitHub Desktop.
Save prosenjit-manna/974309d28f43fbe0af3b9a849428b5b0 to your computer and use it in GitHub Desktop.
Custom Image with NVM and ubuntu
FROM ubuntu:22.04
USER root
# replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# update the repository sources list
# and install dependencies
RUN apt-get update \
&& apt-get install -y curl \
&& apt-get -y autoclean
# install nvm
# https://github.com/creationix/nvm#install-script
RUN curl --silent -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# nvm environment variables
ENV NVM_DIR=/root/.nvm
ENV NODE_VERSION=20.18.3
# install node and npm
RUN source $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default
# Ensure Node.js is available in the container's PATH
ENV PATH="/root/.nvm/versions/node/v$NODE_VERSION/bin:$PATH"
# Verify installation
RUN node -v && npm -v
CMD ["node"]
# docker build -t itobuz/node-custom-image-1:tagname .
# docker push itobuz/node-custom-image-1:tagname
# docker buildx build --platform linux/arm64 -t itobuz/node-custom-image-1 --push .
# docker buildx build --platform linux/amd64 -t itobuz/node-custom-image-1 --push .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment