There's one last little interesting thing that I want to show you about our current build process in
the container that we're running out of it.
I'm going to start up my container very quickly with Docker run.
We'll do the port mapping again with ADHD ADHD and I'll do Steven Greider slash simple web.
Okay.
So running on for ADHD.
Now I'm going to again visit the application side 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 J.S. file.
I'm going to open up the index not just file right here.
This is the root handler right here that is executed.
Anytime someone visits the root root on a 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 to change from high there to buy there I know I'm not very original I'm going to save this file
definitely saved and get a file save.
Hundred percent save no two ways about it and then I'm going to 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 J.S. after it got copied over and we are running our application
based on that old version of index such as when we modify the index such as 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 going to go through that configuration just yet.
That's going to 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 built command in 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 because there's one more little thing that I want to show you
along those lines.
I'm going to start my running server and then we'll do a docker build.
We're going to target
and then I'll make sure that I do that dot to specify the build context.
So going to run that and oh this is kind of interesting I want you to notice something here during Step
3 We're copying over all of our project files and folders every last one of them.
We just made a change the index not J.S. file and docker has detected that we change one of the files
that copy 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 going to 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 npm install.
All we did was change one of the source code 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 a 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
you make a change to the source code of your project.
So it's come back 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 a quick break and I'll see you in just a minute.