1 00:00:00,850 --> 00:00:06,360 In the last section we took a first stab at our darker file to build out this no J.S. Project but we 2 00:00:06,360 --> 00:00:13,430 very quickly saw that during the run npm install step we got an error message that said NPM not found. 3 00:00:13,530 --> 00:00:18,210 We're seeing this error message because during step number two right here where we tried to execute 4 00:00:18,210 --> 00:00:25,290 the command npm install inside of a temporary container there is no copy of NPM available. 5 00:00:25,290 --> 00:00:29,430 We're seeing this because we are using Alpine as our base image. 6 00:00:29,430 --> 00:00:36,150 Remember we had said that we select our base image based upon the collection of default programs that 7 00:00:36,150 --> 00:00:39,870 we need to successfully build our image by default. 8 00:00:39,870 --> 00:00:41,970 Alpine is a very small image. 9 00:00:41,970 --> 00:00:48,090 It's only about 5 megabytes large and so it has a rather limited set of default programs in suit clued 10 00:00:48,090 --> 00:00:49,220 inside of it. 11 00:00:49,260 --> 00:00:51,810 In fact I kind of like this diagram right here. 12 00:00:51,810 --> 00:00:54,350 What programs are included in the Alpine image. 13 00:00:54,350 --> 00:00:56,570 All this is supposed to be a tumbleweed of sorts. 14 00:00:56,700 --> 00:01:00,440 Not much so there's not a whole lot of stuff going on by default. 15 00:01:00,450 --> 00:01:06,180 Inside the Alpine image you get a couple of very default Linux or Unix programs. 16 00:01:06,180 --> 00:01:10,000 You get that package manager that we use just a little bit ago but that's pretty much it. 17 00:01:10,020 --> 00:01:12,970 You don't get a lot of other stuff for free. 18 00:01:12,990 --> 00:01:18,450 So when you are using the Alpine image and you expect to run some fancy web application depending upon 19 00:01:18,450 --> 00:01:24,900 note J.S. or depending upon Ruby or Java chances are you are gonna have to do some additional fixes 20 00:01:24,900 --> 00:01:27,430 or some additional setup to get this thing working. 21 00:01:27,690 --> 00:01:33,870 Now to solve this issue to solve the issue of NPM not being available inside of our base image we have 22 00:01:33,990 --> 00:01:35,360 two options. 23 00:01:35,400 --> 00:01:39,210 The first option is to find a different base image. 24 00:01:39,330 --> 00:01:45,960 We can try to find a base image that already has node and NPM pre installed inside of it. 25 00:01:45,960 --> 00:01:52,620 Alternatively we can continue using the Alpine image and run an additional command like right here to 26 00:01:52,620 --> 00:01:57,150 attempt to install node J.S. in NPM inside of our image. 27 00:01:57,180 --> 00:02:02,640 So two approaches we can either essentially use someone else's work or we can try to build up our own 28 00:02:02,670 --> 00:02:04,270 image from scratch. 29 00:02:04,470 --> 00:02:08,550 In our case we're going to try using someone else's image. 30 00:02:08,550 --> 00:02:15,360 We're going to find an image that has already been configured to have NPM pre installed inside of it. 31 00:02:15,360 --> 00:02:20,700 So to get started to flip back over to my terminal and we're going to navigate to Docker Hub which you'll 32 00:02:20,700 --> 00:02:26,690 recall is a repository of public images that we can easily pull into our build process. 33 00:02:26,760 --> 00:02:34,650 So I'm going to open up a new tab and navigate to hub dot Docker dot com and then on the top bar I'm 34 00:02:34,650 --> 00:02:42,320 going to find the exploit button you'll see a listing of very popular images Emelia pier and so of course 35 00:02:42,410 --> 00:02:48,760 right there is Alpine we're going to scroll down a little bit and all few options down you'll see a 36 00:02:48,820 --> 00:02:50,510 node listed right here. 37 00:02:50,590 --> 00:02:55,030 If you don't see node listed on here you can always do a search up you're at the top left hand side 38 00:02:55,420 --> 00:02:59,860 and we're essentially just looking for the repository at called Node and it should have a little sub 39 00:02:59,860 --> 00:03:03,570 description of official so we can click on this. 40 00:03:03,760 --> 00:03:05,830 We'll get a short description right here. 41 00:03:05,830 --> 00:03:08,800 Now the description in this case is not super helpful. 42 00:03:08,860 --> 00:03:15,310 It says Oh yeah no J.S. here's what it is but or what are we really downloading like what is this repository. 43 00:03:15,310 --> 00:03:21,390 This repository is a Docker image that has node pre installed on it. 44 00:03:21,520 --> 00:03:26,350 So if we want to we can attempt to build our image based upon this Node 1. 45 00:03:26,410 --> 00:03:31,240 And there's no damage already has node pre installed or he has NPM pre installed and so we don't have 46 00:03:31,240 --> 00:03:37,490 to worry about getting more errors like this where NPM is not found. 47 00:03:37,600 --> 00:03:42,280 Now before we just go and use node willy nilly I want to show you a little bit more inside this description 48 00:03:42,760 --> 00:03:49,210 so you'll see this full description panel right here and then first section in here is supported tags 49 00:03:49,240 --> 00:03:51,460 and respective Docker file links. 50 00:03:51,490 --> 00:03:55,890 So this is a listing of all the different versions of this image that is available. 51 00:03:55,990 --> 00:04:01,740 You can get different versions of node J.S. encapsulated in each of these different tacks. 52 00:04:01,750 --> 00:04:08,170 So for example if I have a application that requires node version six point one four I can find the 53 00:04:08,170 --> 00:04:14,770 tag version six point one for right here and then inside of my Docker file when I specify my base image 54 00:04:15,370 --> 00:04:22,850 I can say node and I can specify the version of it specifically by adding on six point one four. 55 00:04:22,900 --> 00:04:29,620 So this will give me a image that contains a pre installed version of No J.S. specifically version six 56 00:04:29,620 --> 00:04:36,010 point one four of no J.S. now in our case we don't want version six point one four. 57 00:04:36,010 --> 00:04:41,380 Instead I want you to scroll around just a little bit and you'll eventually see one tag in here called 58 00:04:41,590 --> 00:04:42,430 Alpine. 59 00:04:42,430 --> 00:04:49,300 You might have to do a command F search for Alpine and you'll see that while the there's a lot of examples 60 00:04:49,300 --> 00:04:49,870 on it on here. 61 00:04:49,900 --> 00:04:52,040 So here's Alpine right here. 62 00:04:52,090 --> 00:04:54,190 I want you remember this is a tag. 63 00:04:54,220 --> 00:04:56,470 So this is not the name of the repository. 64 00:04:56,470 --> 00:05:01,000 So when you see Alpine right here it doesn't mean that we're supposed to use like Alpine like we were 65 00:05:01,000 --> 00:05:05,160 just before the first word right here is the name of the repository. 66 00:05:05,290 --> 00:05:09,040 You place a colon and then you put down a tag name. 67 00:05:09,040 --> 00:05:14,530 And so in this case when you see Alpine right here it means that we can optionally select node colon 68 00:05:14,620 --> 00:05:15,130 Alpine. 69 00:05:15,770 --> 00:05:17,960 So now you might be curious why would we do this. 70 00:05:17,960 --> 00:05:22,170 Like what is the purpose of Alpine to being tied on to note. 71 00:05:22,180 --> 00:05:29,500 Well Alpine is a term in the darker world for an image that is as small and compact as possible. 72 00:05:29,500 --> 00:05:36,130 Many popular repositories are going to offer Alpine versions of their image in an alpine version of 73 00:05:36,190 --> 00:05:41,420 note in particular means that you're not going to get a bunch of additional pre installed programs. 74 00:05:41,650 --> 00:05:48,610 So the default node installation might include extra programs like say Get or a package manager or I 75 00:05:48,610 --> 00:05:54,630 don't know some fancy text editing tools inside that image when you get the Alpine version of an image. 76 00:05:54,670 --> 00:05:59,680 It means you're getting the absolute most stripped down version of that image possible. 77 00:05:59,740 --> 00:06:04,030 So it's going to essentially have no Jesus and pretty much nothing else. 78 00:06:04,120 --> 00:06:09,670 It will have some very basic programs like say the pin command maybe you know you have to look at the 79 00:06:09,670 --> 00:06:14,680 actual image to figure that out but it might have that pin command you'll have say cat maybe a simple 80 00:06:14,680 --> 00:06:20,860 text editor s simple programs like that but in general you're getting a very stripped down version of 81 00:06:20,860 --> 00:06:22,050 that image. 82 00:06:22,060 --> 00:06:28,630 So for us the Alpine version works just fine because essentially all you and I need is node and NPM 83 00:06:28,870 --> 00:06:34,400 and NPM is included in this node image right here and we need absolutely nothing else. 84 00:06:34,450 --> 00:06:39,800 So we are totally fine using the Alpine version of the node image. 85 00:06:40,140 --> 00:06:40,500 All right. 86 00:06:40,530 --> 00:06:45,960 So with all that in mind now that we've made the change to the frame right here we now have specified 87 00:06:45,990 --> 00:06:52,070 a base image that hopefully is going to include NPM inside of it and I can tell you it definitely is 88 00:06:52,110 --> 00:06:54,450 this is going to have NPM pre installed. 89 00:06:54,450 --> 00:06:55,950 We're definitely good to go. 90 00:06:56,010 --> 00:07:01,630 So let's now try to rebuild our image with this change and see if that error message goes away. 91 00:07:01,650 --> 00:07:08,170 First things first do make sure that you save the darker file and then once you save it will fold back 92 00:07:08,170 --> 00:07:14,580 over to the terminal and do a docker build dot again. 93 00:07:14,740 --> 00:07:15,130 All right. 94 00:07:15,280 --> 00:07:19,500 So now you can see that we're downloading the new node Alpine image. 95 00:07:19,600 --> 00:07:24,850 We then get down to step number two right here where we run npm install but very shortly after that 96 00:07:24,880 --> 00:07:26,490 we get a series of error messages. 97 00:07:26,500 --> 00:07:31,900 And the first of which says no such file or directory package dot Jason. 98 00:07:31,900 --> 00:07:36,970 So the package that Jason is a file that exists inside of our current working directory but it looks 99 00:07:36,970 --> 00:07:41,820 like the container is complaining that hey I don't have this file available like Where's the package 100 00:07:41,820 --> 00:07:42,790 that Jason File. 101 00:07:42,790 --> 00:07:45,580 I need this to know which dependencies I need to install. 102 00:07:46,060 --> 00:07:47,600 So let's take a quick pause right here. 103 00:07:47,600 --> 00:07:50,350 We're gonna start to investigate why we're seeing this error message.