WEBVTT

00:00.080 --> 00:06.770
So let's start off in the Docker file where, just like we've done in the reservation's Docker file,

00:06.770 --> 00:16.880
which we can reference here, we're going to go ahead and copy our Prisma schema into the auth container.

00:16.880 --> 00:20.600
So swap this app's reservations out for app slash auth.

00:20.600 --> 00:22.790
So now we have the Prisma schema.

00:24.670 --> 00:32.500
We'll go ahead and run npm prisma generate to generate our client types.

00:32.500 --> 00:39.520
And now if we scroll down in our command here, we can now use the same command that we're using in

00:39.520 --> 00:40.690
reservations.

00:40.690 --> 00:45.370
So I'll copy it because we're going to be using the same shared package.json.

00:45.370 --> 00:50.020
At our root, we know we're going to have the same start prod command that we refactored.

00:50.170 --> 00:56.860
We can run start prod to execute any migrations that are going to be in our current working folder,

00:56.860 --> 01:02.710
which we know is going to be the Prisma folder we copied in the auth service here.

01:03.160 --> 01:07.300
So we're going to execute these migrations in auth when we start up here.

01:07.300 --> 01:11.470
And then finally supply the correct path to the auth service.

01:11.470 --> 01:12.880
Main.js.

01:12.880 --> 01:15.400
So now our Docker file is refactored.

01:15.400 --> 01:17.530
Make sure you go ahead and rebuild it.

01:17.530 --> 01:22.090
So we use the latest code by running build tag auth.

01:22.330 --> 01:27.070
Specify the Dockerfile and go to the root of the project.

01:27.250 --> 01:33.310
Now, just the same as we've done before in reservations, head back to the root docker compose so we

01:33.310 --> 01:37.660
can update our start command to work, just like we did for reservations.

01:37.660 --> 01:44.470
We want to execute any migrations in the Docker container as well as update our client types.

01:45.040 --> 01:49.240
So I'll go ahead and swap out the command here for the reservations one.

01:49.240 --> 01:52.540
And let's simply refactor the path to the schema now.

01:52.540 --> 02:00.370
So we'll go to app slash auth Prisma schema to migrate deploy to execute any migrations we need to.

02:00.610 --> 02:07.300
And now for the Prisma generate command to generate the client types I'll point to app slash auth as

02:07.300 --> 02:07.960
well.

02:08.550 --> 02:13.230
And finally to start up we start up the auth service like so.

02:13.740 --> 02:19.920
Now, just the same as we did, I'll copy the depends on block for reservations and also add this for

02:19.920 --> 02:20.400
auth.

02:20.400 --> 02:25.500
Since we know we're executing migrations against the Postgres database, we want this to be running

02:25.500 --> 02:27.120
before we start up auth.

02:27.330 --> 02:31.500
So now we fully refactored our docker setup to work with Prisma.

02:31.500 --> 02:35.190
We are now ready to start up the auth container.

02:35.190 --> 02:38.520
So let's go ahead and run docker compose up auth.

02:38.520 --> 02:42.960
So just the same as we saw for reservations we have this three stage process.

02:42.960 --> 02:44.400
To start the container up.

02:44.400 --> 02:47.910
We are applying our migration against the database.

02:47.910 --> 02:50.730
So this one it found to create the user table.

02:50.970 --> 02:56.280
We are then generating the latest types and starting up our container.

02:56.280 --> 02:59.790
So this is all working as expected which is excellent.
