1 00:00:01,020 --> 00:00:03,960 In the last couple of videos we discussed Docker and Cuban Eddie's. 2 00:00:04,320 --> 00:00:08,300 Hopefully you had a chance to go through those appendix videos at the very end of the course and get 3 00:00:08,300 --> 00:00:10,880 more friendly with Docker if you didn't know about it already. 4 00:00:11,120 --> 00:00:13,970 Some sign here your doctor Perot now right. 5 00:00:14,000 --> 00:00:15,950 I do not expect you to be a doctor Perot. 6 00:00:15,980 --> 00:00:19,250 I really just expect you to have a basic understanding of what a container is. 7 00:00:19,250 --> 00:00:25,060 When images how to create images how to create containers in a couple of commands around them just to 8 00:00:25,070 --> 00:00:28,330 reinforce them that knowledge in this video we're going to start to dock arise. 9 00:00:28,340 --> 00:00:33,130 Our post service and then we're going to play around with the image and container just a little bit. 10 00:00:34,110 --> 00:00:37,790 So let's get to it in order to dock rise. 11 00:00:37,810 --> 00:00:42,120 Our postal service we're going to have to create an image out of it to make an image remember we make 12 00:00:42,120 --> 00:00:46,710 a docker file and then run the docker build command in this diagram. 13 00:00:46,730 --> 00:00:50,780 I've listed out the different commands that we're going to write out inside of the docker file for the 14 00:00:50,780 --> 00:00:52,070 post project. 15 00:00:52,070 --> 00:00:56,090 The first thing we'll do is specify our base image of node Alpine. 16 00:00:56,420 --> 00:01:01,430 Well then specify a working directory which is going to set the working directory for the rest of all 17 00:01:01,430 --> 00:01:04,410 these commands inside of our Docker file. 18 00:01:04,640 --> 00:01:08,590 Well then copy over just the package not just on file installer dependencies. 19 00:01:08,600 --> 00:01:15,010 Using that file and copy over all the other source code from our project and then finally we'll set 20 00:01:15,010 --> 00:01:21,660 up our default command of NPM start to start up our container so let's flip over to our code editor 21 00:01:21,720 --> 00:01:25,660 and start putting this Docker file together back inside my editor. 22 00:01:25,670 --> 00:01:32,620 I'll find the post directory inside there I'll make a new file called Docker file and remember it has 23 00:01:32,620 --> 00:01:38,150 to have a capital D and no extension on it whatsoever then we'll write out those series of commands 24 00:01:38,150 --> 00:01:40,210 so we're just looking at inside that diagram. 25 00:01:40,620 --> 00:01:50,650 Well first specify our base image well then set up a working directory of slash app we will copy over 26 00:01:50,740 --> 00:01:57,720 just the package dot JS on file and then we will run npm install to install all of our dependencies 27 00:01:59,610 --> 00:02:03,600 after that we will copy over everything else from our post directory. 28 00:02:03,640 --> 00:02:07,410 So it really just means our index not just file. 29 00:02:07,490 --> 00:02:12,410 And then finally we'll setup our default command of NPM start 30 00:02:15,500 --> 00:02:17,760 and that should be at now. 31 00:02:17,770 --> 00:02:19,870 One other thing we're going to do really quickly. 32 00:02:19,870 --> 00:02:24,010 Remember that if you went through those videos in the appendix we usually don't want to include any 33 00:02:24,010 --> 00:02:27,070 install dependencies that are on our local machine. 34 00:02:27,070 --> 00:02:31,870 So in our case that would be the node modules folder in order to make sure that we don't send all those 35 00:02:31,870 --> 00:02:34,760 dependencies over during the image building process. 36 00:02:34,780 --> 00:02:39,510 We're going to create a file inside this post directory called Dot. 37 00:02:39,520 --> 00:02:41,860 Make sure you get a dot in there Docker. 38 00:02:42,070 --> 00:02:49,720 Ignore and then inside of here we will write out node modules like so that's going to make sure that 39 00:02:49,720 --> 00:02:54,220 during the image building process we do not attempt to copy over at that node modules directory because 40 00:02:54,220 --> 00:02:59,800 the image is going to install all the relevant dependencies when it is being built on its own. 41 00:02:59,880 --> 00:03:02,810 OK so let's now close those two files. 42 00:03:02,820 --> 00:03:04,230 Well then go back over to our terminal 43 00:03:07,280 --> 00:03:15,410 I will change into the post directory and inside there we'll do a docker build dot that's going to pull 44 00:03:15,410 --> 00:03:20,780 down the node based image set our working directory copy over a package that Jason install dependencies 45 00:03:20,840 --> 00:03:25,420 using that patch dot Jason File the dependencies should be installed rather quickly. 46 00:03:25,700 --> 00:03:30,410 Will then copy over all of the other files inside of our project and then set up that default command 47 00:03:30,520 --> 00:03:31,660 and at the very end. 48 00:03:31,790 --> 00:03:38,900 We get the I.D. of the image that was just built so we can now create an instance of that image or in 49 00:03:38,900 --> 00:03:44,810 other words a container by copying that idea and running Docker run and then pasting the idea of that 50 00:03:44,810 --> 00:03:48,510 image and there we go. 51 00:03:48,510 --> 00:03:51,690 Looks like our server is running successfully okay. 52 00:03:51,730 --> 00:03:53,150 That's a good step forward. 53 00:03:53,170 --> 00:03:57,640 Let's take a pause right here and then as I mentioned we'll do a quick review on some basic commands 54 00:03:57,640 --> 00:04:02,110 with Docker in the next video just to make sure it's really clear how we can work with a running container.