WEBVTT

00:00.810 --> 00:02.040
-: In this video, we're gonna add in

00:02.040 --> 00:04.290
some artifact sections for our worker

00:04.290 --> 00:07.230
and our server so that we can get some automatic code reload

00:07.230 --> 00:09.180
with those two things as well.

00:09.180 --> 00:11.220
So inside of my scaffold dev file

00:11.220 --> 00:13.170
I'm gonna find my artifact section

00:13.170 --> 00:15.780
and I'll add in another array entry.

00:15.780 --> 00:18.240
As usual, please make sure that you've got that dash

00:18.240 --> 00:21.450
on the same tab line as the one right above it.

00:21.450 --> 00:22.620
If you indent that thing

00:22.620 --> 00:25.710
you're gonna very quickly see an error message.

00:25.710 --> 00:27.990
All right, so we'll add in an artifact section

00:27.990 --> 00:30.210
for how about our server first.

00:30.210 --> 00:32.220
So I'll first specify my image

00:32.220 --> 00:34.110
which is gonna have a name for me

00:34.110 --> 00:37.148
of Steven Griter multi dash server

00:37.148 --> 00:38.430
I think is what we called it.

00:38.430 --> 00:39.960
I'm just gonna do a quick check here.

00:39.960 --> 00:43.263
Here's my server deployment, called it multi-server.

00:44.460 --> 00:46.110
Okay, very good.

00:46.110 --> 00:47.490
I'll then specify the context

00:47.490 --> 00:50.160
which is essentially just the directory for that.

00:50.160 --> 00:51.723
So in this case server.

00:52.890 --> 00:54.480
I'll then specify the Docker file

00:54.480 --> 00:58.353
that I want to use, which is going to be Docker file.dev.

00:59.640 --> 01:01.140
And then we can list out all the different things

01:01.140 --> 01:02.820
that we want to have synced.

01:02.820 --> 01:06.570
So in this case, we're not gonna have any CSS or HTML files.

01:06.570 --> 01:09.480
We really just have JavaScript files inside of our server.

01:09.480 --> 01:14.343
So I'll do *** js:. Like so.

01:15.420 --> 01:18.513
Now we can repeat that same process for worker as well.

01:19.410 --> 01:24.270
So once again, add in a dash image of Steven Griter,

01:24.270 --> 01:25.233
multi worker.

01:26.280 --> 01:30.420
The context is the worker directory for Docker.

01:30.420 --> 01:32.520
We want to tell it to use the docker file

01:32.520 --> 01:35.283
of docker file.dev.

01:36.630 --> 01:41.630
And once again we only really want to sync ***js like so.

01:43.650 --> 01:45.120
Now I want to repeat one more time

01:45.120 --> 01:48.030
because this is a little tricky thing.

01:48.030 --> 01:49.710
The only time that you're going to want this

01:49.710 --> 01:52.590
to use this mode two method of syncing files

01:52.590 --> 01:55.830
is when your different sub-projects have some ability

01:55.830 --> 01:59.370
to detect changes and automatically reload themselves.

01:59.370 --> 02:01.080
So we built that into our server

02:01.080 --> 02:03.300
and our worker projects as well.

02:03.300 --> 02:06.240
Remember the docker file dev for each of those

02:06.240 --> 02:10.860
starts up those projects using the dev script

02:10.860 --> 02:12.600
and that dev script runs Node mod

02:12.600 --> 02:15.360
which watches for changes in the local project directory

02:15.360 --> 02:17.280
in this case, inside the container

02:17.280 --> 02:19.800
and automatically restarts the project.

02:19.800 --> 02:21.990
So if our sub-projects here of server

02:21.990 --> 02:25.140
and worker do not make use of newly synced files

02:25.140 --> 02:27.180
coming in from scaffold, then it's pointless

02:27.180 --> 02:29.700
to try to use Scaffold to sync those files instead.

02:29.700 --> 02:31.050
If we don't have that ability

02:31.050 --> 02:32.670
we would want scaffold to operate

02:32.670 --> 02:35.220
in mode one, which is to say automatically

02:35.220 --> 02:38.163
rebuild the entire image anytime we make a change.

02:40.290 --> 02:41.700
All right, so now that we've added those in

02:41.700 --> 02:43.320
let's do a quick test.

02:43.320 --> 02:46.260
So I'm gonna flip back over to my terminal.

02:46.260 --> 02:48.430
I'll do a scaffold dev once again

02:50.400 --> 02:51.233
and now we're going to see

02:51.233 --> 02:53.550
that we are building those three separate images

02:55.020 --> 02:56.340
those things all got deployed.

02:56.340 --> 02:58.950
We'll see some startup information here really quickly.

02:58.950 --> 03:01.320
There's the server running node mod,

03:01.320 --> 03:04.380
we probably can also see the worker inside of here as well.

03:04.380 --> 03:06.300
It looks like my server has an error around

03:06.300 --> 03:08.460
connecting to Postgres that's totally fine

03:08.460 --> 03:10.830
kind of outside the realm of what we're doing right now.

03:10.830 --> 03:13.830
And eventually it looks like everything is started up.

03:13.830 --> 03:17.130
So I'm gonna very quickly test this inside of my browser.

03:17.130 --> 03:20.223
I'll do a refresh here and yep, still got this running.

03:21.240 --> 03:23.640
So now let's try making a change to our server project

03:23.640 --> 03:25.950
and just make sure that the files get synced

03:25.950 --> 03:28.860
and that the server automatically restarts.

03:28.860 --> 03:32.343
So for that, I'll find my server index.js_file.

03:33.660 --> 03:37.410
And to test out a change, maybe let's try to

03:37.410 --> 03:40.650
hard code some value that we're sending back.

03:40.650 --> 03:42.510
So right now, notice how values all,

03:42.510 --> 03:43.343
remember we're trying to

03:43.343 --> 03:45.750
get that information coming from Postgres.

03:45.750 --> 03:48.900
So rather than sending back some information

03:48.900 --> 03:51.780
coming from Postgres, I'm going to instead

03:51.780 --> 03:53.700
comment out the values line

03:53.700 --> 03:56.190
and then send back some hard coded values.

03:56.190 --> 03:59.730
So I'll just say always send 1, 2, 3 like so.

03:59.730 --> 04:01.500
Again, I'm just doing this to have some change

04:01.500 --> 04:04.710
that we can actually detect inside of our application.

04:04.710 --> 04:06.060
So I'll now save this file.

04:06.990 --> 04:09.150
If I flip back over to my terminal

04:09.150 --> 04:12.480
I'll see that Scaffold has seen that we made a change

04:12.480 --> 04:14.040
and synced that file,

04:14.040 --> 04:17.070
and then we can see that node mod inside of our server pods

04:17.070 --> 04:18.783
has automatically restarted.

04:19.800 --> 04:23.370
So now we can flip back over to our browser, do a refresh,

04:23.370 --> 04:24.203
and I'll see, okay

04:24.203 --> 04:26.190
I probably put in the incorrect format of data.

04:26.190 --> 04:28.590
I think that's probably supposed to be an array of arrays.

04:28.590 --> 04:29.790
So my mistake there.

04:29.790 --> 04:32.490
However, if we open up our network request log

04:32.490 --> 04:33.630
and we look at all

04:33.630 --> 04:36.960
we will see that we did receive an array of 1, 2, 3.

04:36.960 --> 04:39.750
So we definitely successfully saw that change sync

04:39.750 --> 04:42.400
to our server and the server automatically restarted.

04:43.380 --> 04:45.270
All right, so now last thing we can do.

04:45.270 --> 04:46.950
Once we're all done with development

04:46.950 --> 04:49.270
we can stop scaffold by hitting control C

04:51.420 --> 04:53.760
and all those different deployments and services

04:53.760 --> 04:56.283
everything automatically get cleaned up after us.

04:57.120 --> 04:57.953
All right, so that's it.

04:57.953 --> 05:00.360
That's pretty much scaffold in a nutshell.

05:00.360 --> 05:03.390
Personally, I use Scaffold on every Kubernetes project

05:03.390 --> 05:05.550
I work on because it makes it incredibly simple

05:05.550 --> 05:07.860
to first off work on different projects

05:07.860 --> 05:09.270
on your local machine.

05:09.270 --> 05:10.800
And it also makes it really easy

05:10.800 --> 05:13.410
and straightforward to do local development environments.

05:13.410 --> 05:15.990
So like work on a React application or an API

05:15.990 --> 05:19.230
without having to constantly rebuild all these images

05:19.230 --> 05:22.560
and manually redeploy them every time as well.

05:22.560 --> 05:24.090
All right, so I hope you enjoyed this

05:24.090 --> 05:25.650
and we'll take a pause right here.

05:25.650 --> 05:27.240
And that's pretty much it for now.

05:27.240 --> 05:28.440
So I'll catch you later.
