mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-11-04 06:57:12 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			113 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
			
		
		
	
	
			113 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			Docker
		
	
	
	
	
	
# Dockerized nvm development environment
 | 
						|
#
 | 
						|
# This Dockerfile is for building nvm development environment only,
 | 
						|
# not for any distribution/production usage.
 | 
						|
#
 | 
						|
# Please note that it'll use about 1.2 GB disk space and about 15 minutes to
 | 
						|
# build this image, it depends on your hardware.
 | 
						|
 | 
						|
FROM ubuntu:16.04
 | 
						|
LABEL maintainer="Peter Dave Hello <hsu@peterdavehello.org>"
 | 
						|
LABEL name="nvm-dev-env"
 | 
						|
LABEL version="latest"
 | 
						|
 | 
						|
# Set the SHELL to bash with pipefail option
 | 
						|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
 | 
						|
 | 
						|
# Prevent dialog during apt install
 | 
						|
ENV DEBIAN_FRONTEND noninteractive
 | 
						|
 | 
						|
# ShellCheck version
 | 
						|
ENV SHELLCHECK_VERSION=0.7.0
 | 
						|
 | 
						|
# Pick a Ubuntu apt mirror site for better speed
 | 
						|
# ref: https://launchpad.net/ubuntu/+archivemirrors
 | 
						|
ENV UBUNTU_APT_SITE ubuntu.cs.utah.edu
 | 
						|
 | 
						|
# Disable src package source
 | 
						|
RUN sed -i 's/^deb-src\ /\#deb-src\ /g' /etc/apt/sources.list
 | 
						|
 | 
						|
# Replace origin apt package site with the mirror site
 | 
						|
RUN sed -E -i "s/([a-z]+.)?archive.ubuntu.com/$UBUNTU_APT_SITE/g" /etc/apt/sources.list
 | 
						|
RUN sed -i "s/security.ubuntu.com/$UBUNTU_APT_SITE/g" /etc/apt/sources.list
 | 
						|
 | 
						|
# Install apt packages
 | 
						|
RUN apt update         && \
 | 
						|
    apt upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"  && \
 | 
						|
    apt install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"     \
 | 
						|
        coreutils             \
 | 
						|
        util-linux            \
 | 
						|
        bsdutils              \
 | 
						|
        file                  \
 | 
						|
        openssl               \
 | 
						|
        libssl-dev            \
 | 
						|
        locales               \
 | 
						|
        ca-certificates       \
 | 
						|
        ssh                   \
 | 
						|
        wget                  \
 | 
						|
        patch                 \
 | 
						|
        sudo                  \
 | 
						|
        htop                  \
 | 
						|
        dstat                 \
 | 
						|
        vim                   \
 | 
						|
        tmux                  \
 | 
						|
        curl                  \
 | 
						|
        git                   \
 | 
						|
        jq                    \
 | 
						|
        realpath              \
 | 
						|
        zsh                   \
 | 
						|
        ksh                   \
 | 
						|
        gcc-4.8               \
 | 
						|
        g++-4.8               \
 | 
						|
        xz-utils              \
 | 
						|
        build-essential       \
 | 
						|
        bash-completion       && \
 | 
						|
    apt-get clean
 | 
						|
 | 
						|
RUN wget https://github.com/koalaman/shellcheck/releases/download/v$SHELLCHECK_VERSION/shellcheck-v$SHELLCHECK_VERSION.linux.x86_64.tar.xz -O- | \
 | 
						|
    tar xJvf - shellcheck-v$SHELLCHECK_VERSION/shellcheck          && \
 | 
						|
    mv shellcheck-v$SHELLCHECK_VERSION/shellcheck /bin             && \
 | 
						|
    rmdir shellcheck-v$SHELLCHECK_VERSION
 | 
						|
 | 
						|
# Print tool versions
 | 
						|
RUN bash --version | head -n 1 \
 | 
						|
    && zsh --version \
 | 
						|
    && ksh --version || true \
 | 
						|
    && dpkg -s dash | grep ^Version | awk '{print $2}' \
 | 
						|
    && git --version \
 | 
						|
    && curl --version \
 | 
						|
    && wget --version \
 | 
						|
    && shellcheck -V
 | 
						|
 | 
						|
# Add user "nvm" as non-root user
 | 
						|
RUN useradd -ms /bin/bash nvm
 | 
						|
 | 
						|
# Set NVM root dir
 | 
						|
ARG NVM_DIR=/home/nvm
 | 
						|
 | 
						|
# Copy and set permission for nvm directory
 | 
						|
COPY . $NVM_DIR
 | 
						|
RUN chown nvm:nvm -R $NVM_DIR
 | 
						|
 | 
						|
# Set sudoer for "nvm"
 | 
						|
RUN echo 'nvm ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
 | 
						|
 | 
						|
# Switch to user "nvm" from now
 | 
						|
USER nvm
 | 
						|
 | 
						|
# nvm
 | 
						|
RUN echo 'export NVM_DIR="${NVM_DIR}/.nvm"'                                       >> "$HOME/.bashrc"
 | 
						|
RUN echo '[ -s "${NVM_DIR}/nvm.sh" ] && . "${NVM_DIR}/nvm.sh"  # This loads nvm' >> "$HOME/.bashrc"
 | 
						|
RUN echo '[ -s "${NVM_DIR}/bash_completion" ] && . "${NVM_DIR}/bash_completion" # This loads nvm bash_completion' >> "$HOME/.bashrc"
 | 
						|
 | 
						|
# nodejs and tools
 | 
						|
RUN source $NVM_DIR/nvm.sh \
 | 
						|
    && nvm install node \
 | 
						|
    && npm install -g doctoc urchin eclint dockerfile_lint \
 | 
						|
    && npm install --prefix $NVM_DIR
 | 
						|
 | 
						|
# Set WORKDIR to nvm directory
 | 
						|
WORKDIR $NVM_DIR
 | 
						|
 | 
						|
ENTRYPOINT ["/bin/bash"]
 |