1 00:00:00,760 --> 00:00:05,530 There's one last little interesting thing that I want to show you about our current build process in 2 00:00:05,530 --> 00:00:07,800 the container that we're running out of it. 3 00:00:07,840 --> 00:00:11,290 I'm going to start up my container very quickly with Docker run. 4 00:00:11,290 --> 00:00:18,000 We'll do the port mapping again with ADHD ADHD and I'll do Steven Greider slash simple web. 5 00:00:18,700 --> 00:00:18,990 Okay. 6 00:00:19,030 --> 00:00:20,580 So running on for ADHD. 7 00:00:20,680 --> 00:00:23,440 Now I'm going to again visit the application side the browser. 8 00:00:23,440 --> 00:00:24,530 I'll refresh the page. 9 00:00:24,760 --> 00:00:27,300 Yep everything's working as we expect. 10 00:00:27,370 --> 00:00:32,620 Now let's try making a change to the source code of our index dot J.S. file. 11 00:00:32,620 --> 00:00:35,980 I'm going to open up the index not just file right here. 12 00:00:35,980 --> 00:00:39,300 This is the root handler right here that is executed. 13 00:00:39,300 --> 00:00:42,870 Anytime someone visits the root root on a running server. 14 00:00:43,000 --> 00:00:47,110 And so as you can see we are sending back a string of simply Hi there. 15 00:00:47,110 --> 00:00:52,090 Let's try making a change to the string and then refreshing the page and seeing what happens. 16 00:00:52,090 --> 00:00:59,190 So I to change from high there to buy there I know I'm not very original I'm going to save this file 17 00:00:59,610 --> 00:01:01,950 definitely saved and get a file save. 18 00:01:01,950 --> 00:01:06,960 Hundred percent save no two ways about it and then I'm going to go back over to the browser and I'll 19 00:01:07,020 --> 00:01:13,390 refresh the page and when I do so you'll notice that we still see hi there appear on the screen. 20 00:01:13,740 --> 00:01:15,630 So what's going on. 21 00:01:15,630 --> 00:01:21,000 Well remember anytime that we create our image or create the container we're taking a snapshot of the 22 00:01:21,000 --> 00:01:22,230 file system. 23 00:01:22,230 --> 00:01:28,710 So we took a snapshot of index dot J.S. after it got copied over and we are running our application 24 00:01:28,770 --> 00:01:35,310 based on that old version of index such as when we modify the index such as file inside of our current 25 00:01:35,310 --> 00:01:36,620 working directory right here. 26 00:01:36,720 --> 00:01:41,640 That change is not going to be automatically reflected inside the container. 27 00:01:41,640 --> 00:01:44,120 If we want it to update the file inside the container. 28 00:01:44,160 --> 00:01:47,770 We're going to have to do some additional fancy configuration. 29 00:01:48,030 --> 00:01:50,300 We're not going to go through that configuration just yet. 30 00:01:50,310 --> 00:01:53,430 That's going to be something that we're going to address on the next application. 31 00:01:53,520 --> 00:01:54,960 But just so you're aware. 32 00:01:54,960 --> 00:01:55,200 Yeah. 33 00:01:55,200 --> 00:01:59,640 Changes we make here not reflected inside the container. 34 00:01:59,680 --> 00:02:05,530 So what would we have to do to get our container to get this new file or to get this new change right 35 00:02:05,530 --> 00:02:06,310 here. 36 00:02:06,310 --> 00:02:09,910 Well we would have to completely rebuild the container. 37 00:02:09,910 --> 00:02:15,640 We would have to rerun the docker built command in attempt to build it again which is going to copy 38 00:02:15,640 --> 00:02:20,380 over the newly changed files then run npm install and then start our server up. 39 00:02:20,590 --> 00:02:23,920 Let's go through that process right now because there's one more little thing that I want to show you 40 00:02:24,040 --> 00:02:27,380 along those lines. 41 00:02:27,550 --> 00:02:32,050 I'm going to start my running server and then we'll do a docker build. 42 00:02:32,050 --> 00:02:32,950 We're going to target 43 00:02:35,700 --> 00:02:39,690 and then I'll make sure that I do that dot to specify the build context. 44 00:02:39,690 --> 00:02:45,870 So going to run that and oh this is kind of interesting I want you to notice something here during Step 45 00:02:45,870 --> 00:02:51,390 3 We're copying over all of our project files and folders every last one of them. 46 00:02:51,660 --> 00:02:57,810 We just made a change the index not J.S. file and docker has detected that we change one of the files 47 00:02:57,810 --> 00:03:03,480 that copy was copied over during that step because we made a change to this step this step right here 48 00:03:03,480 --> 00:03:07,620 Step number three and every step after it has to be executed. 49 00:03:07,650 --> 00:03:13,350 Again in other words when we rebuild our container we have to reinstall all of our dependencies even 50 00:03:13,350 --> 00:03:19,630 though we very clearly did not make a single change to any other dependencies inside of our project. 51 00:03:19,680 --> 00:03:25,260 And so I'm going to argue that that's probably not ideal if we don't make a change to a dependency inside 52 00:03:25,260 --> 00:03:26,030 of the project. 53 00:03:26,070 --> 00:03:28,830 We probably don't want to rerun npm install. 54 00:03:29,010 --> 00:03:33,140 All we did was change one of the source code files of our project. 55 00:03:33,150 --> 00:03:36,850 And again that has nothing to do with our dependencies. 56 00:03:36,900 --> 00:03:41,280 So I think that would be really neat if we could figure out a way to make sure that just by changing 57 00:03:41,310 --> 00:03:46,950 one of our source code files we do not have to rerun npm install and install all of our dependencies 58 00:03:46,950 --> 00:03:50,730 again because even though this is only taking a handful of seconds right now. 59 00:03:50,730 --> 00:03:53,140 Well it's only because we have one single dependency. 60 00:03:53,310 --> 00:03:58,470 If you're working on a real application or a real project it might take several minutes to rerun the 61 00:03:58,470 --> 00:04:04,140 npm install command and I would not want you to have to reinstall all those dependencies every time 62 00:04:04,200 --> 00:04:06,690 you make a change to the source code of your project. 63 00:04:06,720 --> 00:04:11,130 So it's come back the next section and we're gonna figure out a better way to handle copying over our 64 00:04:11,190 --> 00:04:13,930 project files and folders into the container. 65 00:04:13,950 --> 00:04:15,650 So a quick break and I'll see you in just a minute.