1
00:00:02,260 --> 00:00:04,030
So now we're pretty much done

2
00:00:04,030 --> 00:00:06,540
with this module, I have one last note

3
00:00:06,540 --> 00:00:09,393
about multi-stage bills at this point.

4
00:00:10,480 --> 00:00:13,990
As I mentioned already, you can build the entire image

5
00:00:13,990 --> 00:00:16,910
or also select individual stages,

6
00:00:16,910 --> 00:00:19,440
up to which you wanna build in that image,

7
00:00:19,440 --> 00:00:21,943
if you have a multistage Dockerfile.

8
00:00:22,960 --> 00:00:27,120
Now in this scenario, we always build the entire image,

9
00:00:27,120 --> 00:00:29,600
and I guess that makes a lot of sense here,

10
00:00:29,600 --> 00:00:33,430
since ultimately we use this image to spin up a container

11
00:00:33,430 --> 00:00:38,300
where it is optimized and build react code is being served.

12
00:00:38,300 --> 00:00:42,170
But theoretically, we could also just execute

13
00:00:42,170 --> 00:00:45,470
that first stage here if you wanted to.

14
00:00:45,470 --> 00:00:50,470
So for example, here we could build in our front end folder

15
00:00:52,630 --> 00:00:57,630
this frontendockerfile.prod file,

16
00:00:58,000 --> 00:01:00,950
which is that multistage built Dockerfile.

17
00:01:00,950 --> 00:01:04,670
But instead of building it entirely as we did before,

18
00:01:04,670 --> 00:01:07,760
we can just build parts of it by adding

19
00:01:07,760 --> 00:01:10,660
the dash dash target option.

20
00:01:10,660 --> 00:01:14,370
And now we can target build stages by their name.

21
00:01:14,370 --> 00:01:17,420
So I could target this build stage.

22
00:01:17,420 --> 00:01:20,400
So this first stage which I named build here.

23
00:01:20,400 --> 00:01:23,470
If it's named differently, you use the different name.

24
00:01:23,470 --> 00:01:25,760
So here we could then enter build here,

25
00:01:25,760 --> 00:01:29,790
and this would cause the image build process to stop

26
00:01:29,790 --> 00:01:32,940
after this stage was processed.

27
00:01:32,940 --> 00:01:35,870
So we would then just build decode,

28
00:01:35,870 --> 00:01:39,310
but not spin up that server in that image

29
00:01:39,310 --> 00:01:40,700
which we're building now.

30
00:01:40,700 --> 00:01:43,250
Now that's not too helpful here,

31
00:01:43,250 --> 00:01:45,060
but of course you could have an image.

32
00:01:45,060 --> 00:01:48,380
You could have a Dockerfile with multiple stages.

33
00:01:48,380 --> 00:01:50,520
Let's say one stage for testing,

34
00:01:50,520 --> 00:01:52,630
one stage for running a server.

35
00:01:52,630 --> 00:01:55,700
And sometimes you just wanna run up to the tests.

36
00:01:55,700 --> 00:01:58,650
Sometimes you also wanna run up to the server.

37
00:01:58,650 --> 00:02:02,630
So if the dash dash target flag, you can do just that.

38
00:02:02,630 --> 00:02:05,920
And now it stopped after it ran the build command.

39
00:02:05,920 --> 00:02:10,430
It does not continue to starting the nginx server

40
00:02:10,430 --> 00:02:15,340
in that image, which I now built based on this Dockerfile

41
00:02:15,340 --> 00:02:18,980
to be precise, based on this first stage.

42
00:02:18,980 --> 00:02:21,660
It is a feature which I also wanna highlight here

43
00:02:21,660 --> 00:02:25,990
because it can become handy in more complex projects

44
00:02:25,990 --> 00:02:28,330
and more complex Dockerfiles,

45
00:02:28,330 --> 00:02:30,713
which might have multiple stages.

