1
00:00:02,110 --> 00:00:05,540
Now talking about copy in the dockerfile,

2
00:00:05,540 --> 00:00:07,310
there is one extra,

3
00:00:07,310 --> 00:00:10,670
bit of configuration we can add to our project.

4
00:00:10,670 --> 00:00:14,003
At the moment this copy instruction copies everything

5
00:00:14,003 --> 00:00:17,370
in the folder where this Docker file lives,

6
00:00:17,370 --> 00:00:19,010
because I just have a dot here,

7
00:00:19,010 --> 00:00:20,530
which means everything.

8
00:00:20,530 --> 00:00:23,460
Previously, I also copied just package dot Jason

9
00:00:23,460 --> 00:00:24,900
to the working directory,

10
00:00:24,900 --> 00:00:28,710
but in this step we copy actually everything.

11
00:00:28,710 --> 00:00:30,690
Now this is something we can do,

12
00:00:30,690 --> 00:00:33,700
everything works, but we can also restrict

13
00:00:33,700 --> 00:00:35,600
what gets copied here.

14
00:00:35,600 --> 00:00:40,600
And we do this by adding a dot Docker ignore file here

15
00:00:40,770 --> 00:00:43,110
the dot at the beginning is important.

16
00:00:43,110 --> 00:00:46,620
If you know git this concept might be familiar to you

17
00:00:46,620 --> 00:00:49,820
with Git, which is a source control tool,

18
00:00:49,820 --> 00:00:51,550
has nothing to do with Docker.

19
00:00:51,550 --> 00:00:53,660
With Git we can add gitignore,

20
00:00:53,660 --> 00:00:57,600
to tell Git to which possibly existing folders and files

21
00:00:57,600 --> 00:01:01,713
in our project folder should not be committed to git.

22
00:01:02,610 --> 00:01:04,060
With Docker ignore,

23
00:01:04,060 --> 00:01:07,020
we can specify which folders and files,

24
00:01:07,020 --> 00:01:11,110
should not be copied by a copy instruction.

25
00:01:11,110 --> 00:01:12,930
And here in Docker ignore

26
00:01:12,930 --> 00:01:16,460
we could also add node modules to ensure,

27
00:01:16,460 --> 00:01:20,440
that if a node modules folder would exist here,

28
00:01:20,440 --> 00:01:21,580
which it doesn't,

29
00:01:21,580 --> 00:01:22,820
but which would be the case,

30
00:01:22,820 --> 00:01:25,680
if they would run npm install on my host machine,

31
00:01:25,680 --> 00:01:27,300
in this project folder,

32
00:01:27,300 --> 00:01:31,560
that such a folder is not getting copied into the image.

33
00:01:31,560 --> 00:01:33,390
Because if we would copy it in,

34
00:01:33,390 --> 00:01:34,810
if it would exist,

35
00:01:34,810 --> 00:01:38,160
we would overwrite the node modules folder

36
00:01:38,160 --> 00:01:39,880
which is created inside of the image

37
00:01:39,880 --> 00:01:41,160
with npm install.

38
00:01:41,160 --> 00:01:42,500
And that's bad,

39
00:01:42,500 --> 00:01:45,802
because our locally existing node modules folder

40
00:01:45,802 --> 00:01:47,610
could be outdated,

41
00:01:47,610 --> 00:01:49,730
could be missing important dependencies

42
00:01:49,730 --> 00:01:51,843
which we did add inside of the image,

43
00:01:51,843 --> 00:01:53,854
Or even if it is up to date,

44
00:01:53,854 --> 00:01:58,110
it simply makes that copy process take a bit longer.

45
00:01:58,110 --> 00:02:01,230
So that's why adding such a Docker ignore file,

46
00:02:01,230 --> 00:02:04,854
could make sense to ensure that certain folders or files

47
00:02:04,854 --> 00:02:07,065
in this case the node modules folder,

48
00:02:07,065 --> 00:02:08,794
are not getting copied

49
00:02:08,794 --> 00:02:09,905
into your image

50
00:02:09,905 --> 00:02:13,750
whenever you use the copy instruction.

51
00:02:13,750 --> 00:02:15,270
So that's why I'm adding it here,

52
00:02:15,270 --> 00:02:17,600
even though we don't strictly need it here.

53
00:02:17,600 --> 00:02:20,650
But again, in case I had a node modules folder,

54
00:02:20,650 --> 00:02:23,920
this ensures it's not getting copied into the image,

55
00:02:23,920 --> 00:02:25,374
but instead we stick to the one

56
00:02:25,374 --> 00:02:29,343
which is created inside of the image with npm install.

