Skip to content

tgagor/docker-nvm-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Two ways to integrate NVM in Docker images

This is just an example of my approach to make NVM easily available in Docker images or CI/CD.

Hack used here allow to just copy your code to the Docker image and install whatever version of Node you need.

Explanation

The structure of Docker images:

graph LR
    O(ubuntu:22.04) -- source nvm --> A
    O(ubuntu:22.04) -- wrap nvm --> B
    A(tgagor/base-v1/nvm) --> C(tgagor/base-v1/node:18)
    B(tgagor/base-v2/nvm) --> E(tgagor/base-v2/node:18)
Loading

All images are based on Ubunut 22.04 and install the same version of NVM.

  • tgagor/base-v1/* images try to source nvm.sh,
  • tgagor/base-v2/* images use wrappers (my preferred solution).

You can build all images calling:

make build

You can list them by:

make list

You can run tests by:

make test

Summing up the tests:

  • v1 images can't call node without sourcing nvm.sh each time - so it's possible... but it's painful.
  • v2 just works as it was running on your local machine.

About

Repo with example NVM in Docker image implementation for use in easy CI/CD

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published