Skip to content

Instantly share code, notes, and snippets.

@knksmith57
Last active February 11, 2021 21:06
Show Gist options
  • Save knksmith57/2a0f8f14982eab1aaea19a73b309d413 to your computer and use it in GitHub Desktop.
Save knksmith57/2a0f8f14982eab1aaea19a73b309d413 to your computer and use it in GitHub Desktop.
selenium/standalone-chrome w/ Node.js installed via nvm

Uses LTS Dubnium as the default version but an active LTS is advised.

The installed version is configurable via build arg using NODE_VERSION, and resolved directly by nvm:

❯ docker build . --build-arg=NODE_VERSION=lts/fermium

❯ docker build . --build-arg=NODE_VERSION=14.15

❯ docker build . --build-arg=NODE_VERSION=12
FROM selenium/standalone-chrome:latest
ARG NODE_VERSION=lts/dubnium
ENV NODE_VERSION=$NODE_VERSION \
NVM_DIR=/opt/nvm
USER root
RUN mkdir -p $NVM_DIR \
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh \
| PROFILE=/dev/null bash \
&& ln -s "$(bash -c 'source /opt/nvm/nvm.sh && echo $NVM_BIN')"/* /usr/local/bin/
ENV npm_config_prefix=/usr/local \
NO_UPDATE_NOTIFIER=
##
## insert any global npm installs here
##
RUN npm install --global yarn
USER seluser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment