1
00:00:04,860 --> 00:00:11,520
So let's say the changes in this file control as on the windows or command as on Mac like that changes

2
00:00:11,520 --> 00:00:12,420
were saved.

3
00:00:12,540 --> 00:00:19,410
And now let's doc arise this application and for that we will create Docker file.

4
00:00:19,440 --> 00:00:26,070
Now I recommend to you to install extensions called Docker and Kubernetes.

5
00:00:26,370 --> 00:00:30,600
So go to extensions here and enter first Docker here.

6
00:00:31,610 --> 00:00:33,680
Select Docker and click install.

7
00:00:33,680 --> 00:00:40,970
In my case, Docker extension was already installed and afterwards please also install Kubernetes extension,

8
00:00:40,970 --> 00:00:43,670
find it like that and install it as well.

9
00:00:43,670 --> 00:00:49,430
In my case, Kubernetes extension was installed earlier, so now we are good to go.

10
00:00:49,430 --> 00:00:57,230
And also in order to build actual Docker image, you have to run Docker on your computer.

11
00:00:57,260 --> 00:01:04,849
Before we did not launch Docker in order to start Mini Kube Kubernetes cluster, but now we need Docker

12
00:01:04,849 --> 00:01:07,310
in order to build Docker image.

13
00:01:07,700 --> 00:01:08,540
That's why.

14
00:01:08,540 --> 00:01:13,190
Please go ahead and install Docker if it is not installed on your computer.

15
00:01:13,700 --> 00:01:15,650
Enter Docker download.

16
00:01:17,260 --> 00:01:24,460
Go to this link and install Docker desktop which is available for Windows macOS.

17
00:01:24,460 --> 00:01:29,020
And also you could install Docker directly on Linux like systems.

18
00:01:29,560 --> 00:01:33,190
So please go ahead and install Docker afterwards.

19
00:01:33,190 --> 00:01:34,000
Please run it.

20
00:01:34,000 --> 00:01:35,470
I'll run it like that.

21
00:01:35,470 --> 00:01:37,270
I already installed it before.

22
00:01:37,780 --> 00:01:41,980
Now here I see icon docker is starting here.

23
00:01:41,980 --> 00:01:43,600
I see information about that.

24
00:01:44,230 --> 00:01:45,250
I'll wait a bit.

25
00:01:45,250 --> 00:01:53,150
Meanwhile, let's create a docker file inside of the case web hello folder because we are creating now

26
00:01:53,150 --> 00:01:56,830
a separate application in the k8s root folder.

27
00:01:56,830 --> 00:02:03,880
So let's create docker file here, new file and name it Docker file like that.

28
00:02:04,780 --> 00:02:11,440
Notice that Visual Studio code recognized type of this file and it has added to Icon Docker.

29
00:02:11,890 --> 00:02:18,160
And here in the Docker file, let's add instructions how we would like to build custom Docker image.

30
00:02:18,460 --> 00:02:25,240
I'll again grab contents of this Docker file and paste here in order to save some time and there are

31
00:02:25,240 --> 00:02:26,560
following instructions.

32
00:02:26,560 --> 00:02:32,530
We will use Node Alpine as a base image for our custom image.

33
00:02:32,740 --> 00:02:36,310
Here we set working directory as slash.

34
00:02:36,310 --> 00:02:40,570
Up next, we expose port 3000 afterwords.

35
00:02:40,570 --> 00:02:48,970
We copy two files, package the JSON and package this log the JSON which are present here and then we

36
00:02:48,970 --> 00:02:57,850
run an RPM install when we will build this custom image and after NPM install we are copying all remaining

37
00:02:57,850 --> 00:03:01,390
files from this folder where a Docker file is located.

38
00:03:01,390 --> 00:03:10,270
In our example, it will be just single file index images and this file will be copied to the app folder

39
00:03:10,270 --> 00:03:11,860
inside of the image.

40
00:03:13,740 --> 00:03:20,040
If you are not familiar with those steps and don't know what from work are expose and so on mean.

41
00:03:20,040 --> 00:03:26,820
I highly recommend you to find Docker Crash course and go through it in order to understand how Docker

42
00:03:26,820 --> 00:03:29,900
works and how you are able to build custom images.

43
00:03:29,910 --> 00:03:36,660
This course is not a Docker course, so we copy all the remaining application files to target folder

44
00:03:36,660 --> 00:03:45,060
up and finally we add instruction CMD stands for command, which actually indicates which command will

45
00:03:45,060 --> 00:03:52,860
be executed when corresponding container based on this custom rebuilt image will be started and we want

46
00:03:52,860 --> 00:03:55,230
to run and PM start command.

47
00:03:55,260 --> 00:04:01,110
But what happens now if we enter in PM start in our project folder.

48
00:04:01,140 --> 00:04:02,130
Let's try that.

49
00:04:02,130 --> 00:04:06,990
Let's say if throws changes in docker file save and let's open up again.

50
00:04:06,990 --> 00:04:08,130
Embedded Terminal.

51
00:04:08,160 --> 00:04:16,620
I am still in k8s web hello folder and here in this folder there was index dot mdgs file and here let's

52
00:04:16,620 --> 00:04:19,019
enter and PM start command.

53
00:04:21,019 --> 00:04:24,530
And what I see, I see missing script start.

54
00:04:25,610 --> 00:04:32,660
Now our application will not launch anything if you enter and PM start command in order to be able to

55
00:04:32,660 --> 00:04:39,170
run our application start web server, we need to modify package the JSON file.

56
00:04:39,200 --> 00:04:40,100
Let's do that.

57
00:04:40,130 --> 00:04:46,250
Let's open up package the JSON file and here you'll find scripts section.

58
00:04:46,250 --> 00:04:49,370
And there was just a single default script test.

59
00:04:49,910 --> 00:04:54,740
Let's actually replace test with start like that.

60
00:04:54,740 --> 00:05:01,610
And here in double quotes type note index dot MDGs.

61
00:05:02,630 --> 00:05:12,890
So now there will be a start script and it will essentially run using controlled file index dot MDGs

62
00:05:13,070 --> 00:05:19,280
and this will start actually our express web server on the port 3000.

63
00:05:20,250 --> 00:05:22,020
That's what we discussed here.

64
00:05:22,560 --> 00:05:24,300
Let's save changes in package.

65
00:05:24,300 --> 00:05:33,240
The JSON file now in PM start is available and we are able now to build our image.

66
00:05:33,360 --> 00:05:38,310
If you want to create custom image, you need to utilize Docker, build command.

67
00:05:38,490 --> 00:05:43,790
And usually this command is entered in the folder where Docker file is located.

68
00:05:43,800 --> 00:05:50,730
This, this folder in our example here and if I list files and folders here, I'll find Docker file

69
00:05:51,270 --> 00:05:58,320
and Docker file contents are here from work, they're exposed and so on till cmd.

70
00:05:59,640 --> 00:06:09,270
Now let's build the Docker image and also we will add tag to this custom built Docker image and tag

71
00:06:09,270 --> 00:06:14,460
will include all the username of your account at Docker Hub.

72
00:06:14,670 --> 00:06:22,260
If you don't have a Docker Hub account, please go to Hub Docker dot com and create account.

73
00:06:22,650 --> 00:06:26,310
I already have an account and here is my username.

74
00:06:27,090 --> 00:06:33,570
Please create your account and choose your username and afterwards you will be able to push repositories

75
00:06:33,570 --> 00:06:36,120
to Docker Hub under your account.

76
00:06:37,590 --> 00:06:43,320
And when you push repositories, you will find them here in the repositories section.

77
00:06:43,440 --> 00:06:48,330
Now, under my account, there are no repositories in this namespace.

78
00:06:49,380 --> 00:06:57,060
So let's go back to Visual Studio code and here let's build custom image for our application.

79
00:06:57,690 --> 00:07:00,730
Let's use command, docker build.

80
00:07:00,840 --> 00:07:03,480
Next will be path to Docker file.

81
00:07:03,510 --> 00:07:09,590
I'll use simply dot because now I'm inside of the folder where Docker file was created.

82
00:07:09,600 --> 00:07:11,160
So Docker built dot.

83
00:07:11,310 --> 00:07:16,110
Next let's add tag to our image using the first option.

84
00:07:16,260 --> 00:07:19,860
Then we'll be user name of your GitHub account.

85
00:07:19,890 --> 00:07:22,080
In my case, I'll type mine.

86
00:07:22,920 --> 00:07:26,490
And after a slash, I'll give a name to the repository.

87
00:07:26,640 --> 00:07:27,620
Let's name it.

88
00:07:27,630 --> 00:07:31,620
Same as we named this folder k eight se.

89
00:07:32,890 --> 00:07:33,250
Desk.

90
00:07:33,250 --> 00:07:33,850
Web desk.

91
00:07:33,860 --> 00:07:34,390
Hello?

92
00:07:34,630 --> 00:07:35,440
Like that.

93
00:07:36,040 --> 00:07:38,560
Let's build this image using Docker.

94
00:07:38,560 --> 00:07:39,520
Build command.

95
00:07:41,610 --> 00:07:42,690
Building image.

96
00:07:45,510 --> 00:07:53,400
Notice that in my case base image was already present in the cache and other layers were also cached

97
00:07:53,400 --> 00:07:55,620
and finally image was built.

98
00:07:55,770 --> 00:08:00,780
Now if I enter command docker images and add grep.

99
00:08:01,930 --> 00:08:04,570
And here will be K eight as well.

100
00:08:05,200 --> 00:08:11,230
I'll find image that is now available in our local images repository.

101
00:08:11,410 --> 00:08:15,190
Here is name of the image which we just built.

102
00:08:15,310 --> 00:08:21,400
Tech is latest because in this command which I just entered, I did not specify a tag which you are

103
00:08:21,400 --> 00:08:26,440
able to specify after on here, but I build image with latest tag.

104
00:08:26,470 --> 00:08:35,260
So that's why tag here is latest and here is the ID of the build image and size of the image.

