In the last section we took a first stab at our darker file to build out this no J.S. Project but we
very quickly saw that during the run npm install step we got an error message that said NPM not found.
We're seeing this error message because during step number two right here where we tried to execute
the command npm install inside of a temporary container there is no copy of NPM available.
We're seeing this because we are using Alpine as our base image.
Remember we had said that we select our base image based upon the collection of default programs that
we need to successfully build our image by default.
Alpine is a very small image.
It's only about 5 megabytes large and so it has a rather limited set of default programs in suit clued
inside of it.
In fact I kind of like this diagram right here.
What programs are included in the Alpine image.
All this is supposed to be a tumbleweed of sorts.
Not much so there's not a whole lot of stuff going on by default.
Inside the Alpine image you get a couple of very default Linux or Unix programs.
You get that package manager that we use just a little bit ago but that's pretty much it.
You don't get a lot of other stuff for free.
So when you are using the Alpine image and you expect to run some fancy web application depending upon
note J.S. or depending upon Ruby or Java chances are you are gonna have to do some additional fixes
or some additional setup to get this thing working.
Now to solve this issue to solve the issue of NPM not being available inside of our base image we have
two options.
The first option is to find a different base image.
We can try to find a base image that already has node and NPM pre installed inside of it.
Alternatively we can continue using the Alpine image and run an additional command like right here to
attempt to install node J.S. in NPM inside of our image.
So two approaches we can either essentially use someone else's work or we can try to build up our own
image from scratch.
In our case we're going to try using someone else's image.
We're going to find an image that has already been configured to have NPM pre installed inside of it.
So to get started to flip back over to my terminal and we're going to navigate to Docker Hub which you'll
recall is a repository of public images that we can easily pull into our build process.
So I'm going to open up a new tab and navigate to hub dot Docker dot com and then on the top bar I'm
going to find the exploit button you'll see a listing of very popular images Emelia pier and so of course
right there is Alpine we're going to scroll down a little bit and all few options down you'll see a
node listed right here.
If you don't see node listed on here you can always do a search up you're at the top left hand side
and we're essentially just looking for the repository at called Node and it should have a little sub
description of official so we can click on this.
We'll get a short description right here.
Now the description in this case is not super helpful.
It says Oh yeah no J.S. here's what it is but or what are we really downloading like what is this repository.
This repository is a Docker image that has node pre installed on it.
So if we want to we can attempt to build our image based upon this Node 1.
And there's no damage already has node pre installed or he has NPM pre installed and so we don't have
to worry about getting more errors like this where NPM is not found.
Now before we just go and use node willy nilly I want to show you a little bit more inside this description
so you'll see this full description panel right here and then first section in here is supported tags
and respective Docker file links.
So this is a listing of all the different versions of this image that is available.
You can get different versions of node J.S. encapsulated in each of these different tacks.
So for example if I have a application that requires node version six point one four I can find the
tag version six point one for right here and then inside of my Docker file when I specify my base image
I can say node and I can specify the version of it specifically by adding on six point one four.
So this will give me a image that contains a pre installed version of No J.S. specifically version six
point one four of no J.S. now in our case we don't want version six point one four.
Instead I want you to scroll around just a little bit and you'll eventually see one tag in here called
Alpine.
You might have to do a command F search for Alpine and you'll see that while the there's a lot of examples
on it on here.
So here's Alpine right here.
I want you remember this is a tag.
So this is not the name of the repository.
So when you see Alpine right here it doesn't mean that we're supposed to use like Alpine like we were
just before the first word right here is the name of the repository.
You place a colon and then you put down a tag name.
And so in this case when you see Alpine right here it means that we can optionally select node colon
Alpine.
So now you might be curious why would we do this.
Like what is the purpose of Alpine to being tied on to note.
Well Alpine is a term in the darker world for an image that is as small and compact as possible.
Many popular repositories are going to offer Alpine versions of their image in an alpine version of
note in particular means that you're not going to get a bunch of additional pre installed programs.
So the default node installation might include extra programs like say Get or a package manager or I
don't know some fancy text editing tools inside that image when you get the Alpine version of an image.
It means you're getting the absolute most stripped down version of that image possible.
So it's going to essentially have no Jesus and pretty much nothing else.
It will have some very basic programs like say the pin command maybe you know you have to look at the
actual image to figure that out but it might have that pin command you'll have say cat maybe a simple
text editor s simple programs like that but in general you're getting a very stripped down version of
that image.
So for us the Alpine version works just fine because essentially all you and I need is node and NPM
and NPM is included in this node image right here and we need absolutely nothing else.
So we are totally fine using the Alpine version of the node image.
All right.
So with all that in mind now that we've made the change to the frame right here we now have specified
a base image that hopefully is going to include NPM inside of it and I can tell you it definitely is
this is going to have NPM pre installed.
We're definitely good to go.
So let's now try to rebuild our image with this change and see if that error message goes away.
First things first do make sure that you save the darker file and then once you save it will fold back
over to the terminal and do a docker build dot again.
All right.
So now you can see that we're downloading the new node Alpine image.
We then get down to step number two right here where we run npm install but very shortly after that
we get a series of error messages.
And the first of which says no such file or directory package dot Jason.
So the package that Jason is a file that exists inside of our current working directory but it looks
like the container is complaining that hey I don't have this file available like Where's the package
that Jason File.
I need this to know which dependencies I need to install.
So let's take a quick pause right here.
We're gonna start to investigate why we're seeing this error message.