Skip to content

zolweb/docker-npm

Repository files navigation

npm and related build and dev tools

Fork of https://github.com/mkenney/docker-npm and fork of https://github.com/fernandoacorreia/docker-npm Please feel free to create an issue or open a pull request if you need support or would like to contribute.

Portable node, package managers and build tools

Announcements

2022-04-29

  • add node v18

2021-11-17

  • add node v16

2020-07-27

  • add node v12 and v14, remove node < 8

Tagged Images

Images are tagged according to the installed Node version and operating system. Package versions are not pinned, instead npm is executed to install current versions of each package. If stability issues arise, I will pin package versions in a Dockerfile for that Node/OS version and create a image tagged as stable based on it. Please let me know if you run into this situation.

Alpine

Based on node:alpine. This image should be considered under development and may not be as stable as versioned images.

Based on node:14-alpine.

...

Debian

Based on node:latest. This image should be considered under development and may not be as stable as versioned images.

Based on node:14-bullseye.

...

About

The docker image includes a script (run-as-user) that allows commands to write files as either the current user or the owner/group of the current directory, which the shell scripts take advantage of to make sure files are created with your preferred permissions rather than root.

Images & Wrapper Scripts

The images contain the latest stable bower, generate-md, grunt, gulp, node, npm, npx, and yarn, binaries for node. The included run-as-user script has three methods of determining which uid and gid to execute as:

  • By default, it will execute with a uid and gid that matches the current directory (the one that gets mounted into /src).

  • In order to take advantage of public key authentication when installing packages from private repositories, all the wrapper scripts will attempt to mount your ~/.ssh directory into the container. When that is successful, the script will run as the uid and gid of the owner of ~/.ssh (you).

    Most software that takes advantage of public key authentication protocols do so over SSH, and by default, send the current user name as the login name. Because this process is executing out of a segregated container, it knows nothing about the current user's name and will instead try to login as a user named dev. In order to work around this, you need to create a SSH configuration that specifies the correct username.

    In your ~/.ssh folder create a file called config. In that file you need to specify the correct username. For example, to specify your login name for all hosts:

    Host *
        User mkenney

    You can easily be more explicit as well, specifying by host or with additional wildcards. Google is your friend.

    Host github.com
        User mkenney
  • You can also explicitly specify the uid and gid to use at runtime by defining the PUID and PGID environment variables when executing the container, this is quite useful in automated build systems:

    docker run \
        --rm \
        -it \
        -v $(pwd):/src:rw \
        -e "PUID=<user id>" \
        -e "PGID=<group id>" \
        mkenney/npm:latest <commands>

If you would to see like additional node modules and/or wrapper scripts added to this project please feel free to create an issue or open a pull request.

About

Wrapper of mkenney/npm to allow make

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published