-: There's one last little interesting thing
that I want to show you about our current build process
and the container that we're running out of it.
I'm gonna start up my container very quickly
with docker run.
We'll do the port mapping again with 80, 80, 80, 80.
And I'll do Stephen Grider slash simple web.
Okay, so running on port 80, 80.
Now I'm going to again
visit the application inside the browser.
I'll refresh the page.
Yep, everything's working as we expect.
Now let's try making a change to the source code
of our index dot js file.
I'm going to open up the index dot js file right here.
This is the route handler right here,
that is executed anytime someone visits the root route
on our running server.
And so as you can see,
we are sending back a string of simply 'Hi there'.
Let's try making a change to the string
and then refreshing the page and seeing what happens.
So I'm gonna change from 'Hi there' to 'Bye there'.
I know I'm not very original.
I'm gonna save this file.
Definitely saved.
I'm gonna file save. A hundred percent save.
No two ways about it.
And then I'm gonna go back over to the browser
and I'll refresh the page.
And when I do, so you'll notice
that we still see 'Hi there' appear on the screen.
So what's going on?
Well, remember,
anytime that we create our image
or create the container,
we're taking a snapshot of the file system.
So we took a snapshot of index dot js
after it got copied over
and we are running our application
based on that old version of index dot js.
When we modify the index dot js file
inside of our current working directory right here,
that change is not going to be automatically reflected
inside the container.
If we want it to update the file inside the container,
we're going to have to do
some additional fancy configuration.
We're not gonna go through that configuration just yet.
That's gonna be something that we're going to address
on the next application.
But just so you're aware,
yeah, changes we make here
not reflected inside the container.
So what would we have to do
to get our container
to get this new file
or to get this new change, right here?
Well, we would have to completely rebuild the container.
We would have to rerun the docker build command
and attempt to build it again,
which is going to copy over the newly changed files,
then run NPM install
and then start our server up.
Let's go through that process right now,
cause there's one more little thing
that I wanna show you along those lines.
Okay, so I'm gonna stop my running server
and then we'll do a docker build.
We're gonna tag it
and then I'll make sure that I do the dot
to specify the build context.
So I'm gonna run that...
And, oh, this is kind of interesting.
I want you to notice something here.
During step three, we are copying over
all of our project files and folders.
Every last one of them.
We just made a change to the index do js file.
And Docker has detected
that we changed one of the files
that was copied over during that step
Because we made a change to this step,
this step right here. Step number three
and every step after it,
has to be executed again.
In other words, when we rebuild our container,
we have to reinstall all of our dependencies,
even though we very clearly
did not make a single change
to any other dependencies
inside of our project.
And so I'm gonna argue that
that's probably not ideal.
If we don't make a change to a dependency
inside of the project,
we probably don't want to rerun MPM install.
All we did was change one of the source good files
of our project.
And again, that has nothing to do with our dependencies.
So I think that would be really neat
if we could figure out a way
to make sure that
just by changing one of our source code files,
we do not have to rerun NPM install
and install all of our dependencies again,
because even though this is only taking a handful of seconds
right now...
Well it's only because we have one single dependency.
If you're working on a real application
or real project,
it might take several minutes
to rerun the NPM install command.
And I would not want you
to have to reinstall all those dependencies
every time that you make a change
to the source code of your project.
So let's come back to the next section
and we're gonna figure out a better way
to handle copying over our project files and folders
into the container.
So quick break and I'll see you in just a minute.