1

I can create a docker container with PHP and composer with this:

FROM php:fpm
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

Is there any equivalent way to archive the same for node.js and npm? The only solutions I figured so far are:

If I use the last method, the container gets bloated in size as I copy everything over (around 908 MB). So I wonder if there is a smarter way. What folders/files would I have to copy over to just implement node and npm functionality?

Richard Wilson
  • 467
  • 4
  • 14
Wombat98
  • 11
  • 1
  • Node and npm are executables, you install them in the OS you're running inside docker like any other application that you need installed and ready in your container, you don't copy them over or compile them from source...? E.g. https://askubuntu.com/a/1113339 – Mike 'Pomax' Kamermans Jun 22 '21 at 21:55
  • 1
    if you want to avoid the bloat, install it and then copy it from the first stage to a 2nd stage. That way it's built for your OS platform inside the docker container but you don't pick up all the cruft. – Joe Jun 22 '21 at 22:50

0 Answers0