1
00:00:02,070 --> 00:00:04,250
Let's comment in the composer service.

2
00:00:04,250 --> 00:00:06,640
And let's now ensure that we also set up

3
00:00:06,640 --> 00:00:10,330
this container which will now be a utility container,

4
00:00:10,330 --> 00:00:14,230
which will then not only be used internally by Laravel,

5
00:00:14,230 --> 00:00:17,130
but which most importantly can be used by us,

6
00:00:17,130 --> 00:00:21,380
to also set up a Laravel application in the first place.

7
00:00:21,380 --> 00:00:25,280
For this, I'll add another Dockerfile, a custom Dockerfile,

8
00:00:25,280 --> 00:00:29,920
because I will need a base image with some fine tuning.

9
00:00:29,920 --> 00:00:32,500
So here I'll add the composer.dockerfile.

10
00:00:33,450 --> 00:00:35,380
And I'll start with a base image,

11
00:00:35,380 --> 00:00:38,340
which is the composer image.

12
00:00:38,340 --> 00:00:39,520
And that's really great.

13
00:00:39,520 --> 00:00:43,300
If you search Docker Hub, there is a composer base image,

14
00:00:43,300 --> 00:00:45,110
which basically is an image

15
00:00:45,110 --> 00:00:48,380
that has this composer tool already installed,

16
00:00:48,380 --> 00:00:49,873
which of course is awesome.

17
00:00:50,730 --> 00:00:53,450
So we can start on this composer image

18
00:00:53,450 --> 00:00:55,810
and use the latest tag, for example,

19
00:00:55,810 --> 00:00:58,560
to use the very latest image version.

20
00:00:58,560 --> 00:01:02,460
And now here's the reason why I need my custom Dockerfile,

21
00:01:02,460 --> 00:01:05,670
because I want to specify an entry point.

22
00:01:05,670 --> 00:01:08,390
Now as a side note, there would be a way of doing this

23
00:01:08,390 --> 00:01:10,750
in the docker-compose file as well.

24
00:01:10,750 --> 00:01:12,450
But I'll come back to that later.

25
00:01:12,450 --> 00:01:14,080
This is the approach I like

26
00:01:14,080 --> 00:01:15,900
because we have it is very clear,

27
00:01:15,900 --> 00:01:18,700
easy to understand Dockerfile.

28
00:01:18,700 --> 00:01:22,110
In my entry point now is the composer executable

29
00:01:22,110 --> 00:01:26,150
which exists inside of this composer image and container,

30
00:01:26,150 --> 00:01:29,310
unlike on my local host machine as I showed you before,

31
00:01:29,310 --> 00:01:31,870
and I'll add a flag which should be added

32
00:01:31,870 --> 00:01:34,270
to every command which is executed by it.

33
00:01:34,270 --> 00:01:39,270
And that's the --ignore-platform-reqs command.

34
00:01:41,250 --> 00:01:44,110
This ensures that we can run this without any warnings

35
00:01:44,110 --> 00:01:47,223
or errors even if some dependencies would be missing.

36
00:01:48,630 --> 00:01:49,830
Now very important,

37
00:01:49,830 --> 00:01:52,260
we need to set the right working directory

38
00:01:52,260 --> 00:01:57,260
and set this to /var/www/html.

39
00:01:57,900 --> 00:02:01,150
Because that is where our code will later be.

40
00:02:01,150 --> 00:02:04,030
Save this and go back to docker-compose.

41
00:02:04,030 --> 00:02:05,500
Now that we got the Dockerfile,

42
00:02:05,500 --> 00:02:08,080
we can add the build, configuration here

43
00:02:08,080 --> 00:02:12,440
to the composer service and set the context

44
00:02:12,440 --> 00:02:13,623
to ./dockerfiles.

45
00:02:16,020 --> 00:02:21,020
And set the Dockerfile option to compose.dockerfile

46
00:02:21,040 --> 00:02:23,500
because that is the Dockerfile we wanna use here

47
00:02:23,500 --> 00:02:25,520
to build this image.

48
00:02:25,520 --> 00:02:28,280
Now we need to ensure that we expose our

49
00:02:28,280 --> 00:02:31,140
source code directory to that image,

50
00:02:31,140 --> 00:02:34,860
so that this image works on our source code directory,

51
00:02:34,860 --> 00:02:37,690
and when we use it to install Laravel

52
00:02:37,690 --> 00:02:39,510
and set up a Laravel project,

53
00:02:39,510 --> 00:02:42,470
it does so in our source folder.

54
00:02:42,470 --> 00:02:43,690
And it should of course do this

55
00:02:43,690 --> 00:02:47,930
in this /var/www/html folder internally.

56
00:02:47,930 --> 00:02:50,750
So therefore, here we can add a volume

57
00:02:51,630 --> 00:02:56,630
and bind our source folder to this /var/www/html folder

58
00:02:57,700 --> 00:02:59,730
inside of the container.

59
00:02:59,730 --> 00:03:02,660
So now if we use composer to, for example,

60
00:03:02,660 --> 00:03:05,480
create a Laravel application in this folder

61
00:03:05,480 --> 00:03:06,910
inside of the container.

62
00:03:06,910 --> 00:03:11,000
This will then be mirrored back into our source folder

63
00:03:11,000 --> 00:03:13,280
on the local host machine.

64
00:03:13,280 --> 00:03:15,740
That's essentially what I also already showed you

65
00:03:15,740 --> 00:03:20,010
in the last course section with NPM and Node.

66
00:03:20,010 --> 00:03:24,330
And with this done, we can pause for a second,

67
00:03:24,330 --> 00:03:28,450
we now have our free application containers which will need

68
00:03:28,450 --> 00:03:31,560
to run the Laravel application.

69
00:03:31,560 --> 00:03:34,170
And we got this utility container which we need

70
00:03:34,170 --> 00:03:38,230
to create it, we'll need the other two utility containers

71
00:03:38,230 --> 00:03:41,390
for a certain features inside of Laravel.

72
00:03:41,390 --> 00:03:43,420
But for the moment, we can ignore them.

73
00:03:43,420 --> 00:03:45,620
And instead we can start using

74
00:03:45,620 --> 00:03:47,640
the composer utility container

75
00:03:47,640 --> 00:03:49,900
to create a Laravel application.

76
00:03:49,900 --> 00:03:52,000
And then we can see if we can launch

77
00:03:52,000 --> 00:03:53,610
this application with help

78
00:03:53,610 --> 00:03:56,180
of our free containers.

79
00:03:56,180 --> 00:03:58,083
So how do we do that?

