Skip to content

Instantly share code, notes, and snippets.

@garth
Created May 24, 2021 15:18
Show Gist options
  • Save garth/48eabf4b433491501fb97887f6fe8098 to your computer and use it in GitHub Desktop.
Save garth/48eabf4b433491501fb97887f6fe8098 to your computer and use it in GitHub Desktop.
Docker image roughly based on the offical node images, but with support for projects with mixed node versions via Volta
FROM debian:buster
# curl and ca-certificates are needed for volta installation
# git, python and build-essential are needed for legacy package dependencies
RUN apt-get update \
&& apt-get install -y \
curl \
ca-certificates \
git \
python \
build-essential \
--no-install-recommends
RUN groupadd --gid 1000 node \
&& useradd --uid 1000 --gid node --shell /bin/bash --create-home node
# bash will load volta() function via .bashrc
# using $VOLTA_HOME/load.sh
SHELL ["/bin/bash", "-c"]
# since we're starting non-interactive shell,
# we wil need to tell bash to load .bashrc manually
ENV BASH_ENV ~/.bashrc
# needed by volta() function
ENV VOLTA_HOME /node/.volta
# make sure packages managed by volta will be in PATH
ENV PATH $VOLTA_HOME/bin:$PATH
# install volta
RUN curl https://get.volta.sh | bash
RUN volta install node
RUN volta install yarn
CMD [ "node" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment