-: In the last section, we wrote out all
of our application code for the node JS server.
Now that we've got all that stuff put together,
we're going to put together a little docker file
that's gonna be basically identical
to the one that we had put together previously.
This docker file's sole purpose is going to be
to put together this node application.
And so essentially, it's representing this side
of the equation.
This docker file is gonna have nothing to do whatsoever
with our Redis server,
so it's solely concerned with the node app for now.
So let's get started on this.
Inside of my code editor,
I'll find my visits folder.
Inside there I'll make a docker file.
Then inside of here,
we're gonna again see some code that's very identical
to what we put together on our last application.
We'll first specify our base image as node alpine.
We'll then set up a working directory.
We'll again, use app as a working directory.
And then remember, we're gonna use a little strategy
to make sure that we only try to rebuild the image anytime
that we change the package dot JSON file,
and we won't reveal the image
if we make any changes to the source code,
like in the index dot JS file.
To make sure that's the case,
we're going to first copy over
only the package dot JSON file.
We'll then run and PM install to get all
of our different dependencies,
and then we'll copy over all of the rest of our source code
with copy dot dot.
And then finally, we'll start up our server
with CMD NPM start, like so.
Okay, so again, basically the same thing
as what we wrote previously.
Let's now flip over to our terminal
and try building a image out of this docker file.
So I'll go back over to my terminal.
I'm gonna make sure I'm inside of my visits directory,
and I'll run docker build dot.
We're then gonna see the familiar steps.
You might see that red text again,
something that says notice right there.
And you might see the three warnings.
Those are totally fine.
You can completely ignore those.
So then down here at the bottom,
we see the ID of the image that was created.
Now chances are we might not be making a tremendous number
of changes to this image.
So I think we should go ahead
and just tag this image with a name right now,
or give it some name,
so that we don't have to keep carrying around
this ID all the time.
So let's rerun that docker build command,
but rather than putting a dot right at the end,
we'll say docker build,
and then we will dash T to tag it.
And I'll put in my name,
or my docker username that is,
slash the name of our project, which is visits,
and then I'll put a tag on it
by indicating the little colon with latest.
And then after that, I'll put the period to indicate
that we want to build outta the current directory.
All right, so there we go.
That's it.
We've now got our tagged docker image.
So let's take a quick break right here.
And we'll come back the next section,
and we'll start getting a better sense
of how to get this thing to work along together
with a separate container that's running Redis.