Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installation of nvm in a docker container #21

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docker-modules/docker-compose/Installing_NVM_Docker/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Sets the base image of Docker container to Ubuntu 20.04
FROM ubuntu:20.04

# First stage: Build environment to install dependencies and download NVM
FROM node:14 as build-stage

# Update package list and install curl (only needed for the build stage)
RUN apt-get update && apt-get install -y curl

# Copy NVM setup from the build stage
COPY --from=build-stage /app /app

# Set working directory inside the container
WORKDIR /app

# Install NVM using the official installation script
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

# Configure NVM environment to be available in all sessions
RUN echo "export NVM_DIR=\"$HOME/.nvm\"" >> ~/.bashrc \
&& echo "[ -s \"$NVM_DIR/nvm.sh\" ] && \. \"$NVM_DIR/nvm.sh\"" >> ~/.bashrc

# Final stage: Create a clean image without unnecessary build dependencies
FROM node:14

# Source bash profile to load NVM
RUN source ~/.bashrc

# Optional: install a specific Node.js version with NVM if needed
# RUN source ~/.bashrc && nvm install 16