-: In this video, we're gonna add in
some artifact sections for our worker
and our server so that we can get some automatic code reload
with those two things as well.
So inside of my scaffold dev file
I'm gonna find my artifact section
and I'll add in another array entry.
As usual, please make sure that you've got that dash
on the same tab line as the one right above it.
If you indent that thing
you're gonna very quickly see an error message.
All right, so we'll add in an artifact section
for how about our server first.
So I'll first specify my image
which is gonna have a name for me
of Steven Griter multi dash server
I think is what we called it.
I'm just gonna do a quick check here.
Here's my server deployment, called it multi-server.
Okay, very good.
I'll then specify the context
which is essentially just the directory for that.
So in this case server.
I'll then specify the Docker file
that I want to use, which is going to be Docker file.dev.
And then we can list out all the different things
that we want to have synced.
So in this case, we're not gonna have any CSS or HTML files.
We really just have JavaScript files inside of our server.
So I'll do *** js:. Like so.
Now we can repeat that same process for worker as well.
So once again, add in a dash image of Steven Griter,
multi worker.
The context is the worker directory for Docker.
We want to tell it to use the docker file
of docker file.dev.
And once again we only really want to sync ***js like so.
Now I want to repeat one more time
because this is a little tricky thing.
The only time that you're going to want this
to use this mode two method of syncing files
is when your different sub-projects have some ability
to detect changes and automatically reload themselves.
So we built that into our server
and our worker projects as well.
Remember the docker file dev for each of those
starts up those projects using the dev script
and that dev script runs Node mod
which watches for changes in the local project directory
in this case, inside the container
and automatically restarts the project.
So if our sub-projects here of server
and worker do not make use of newly synced files
coming in from scaffold, then it's pointless
to try to use Scaffold to sync those files instead.
If we don't have that ability
we would want scaffold to operate
in mode one, which is to say automatically
rebuild the entire image anytime we make a change.
All right, so now that we've added those in
let's do a quick test.
So I'm gonna flip back over to my terminal.
I'll do a scaffold dev once again
and now we're going to see
that we are building those three separate images
those things all got deployed.
We'll see some startup information here really quickly.
There's the server running node mod,
we probably can also see the worker inside of here as well.
It looks like my server has an error around
connecting to Postgres that's totally fine
kind of outside the realm of what we're doing right now.
And eventually it looks like everything is started up.
So I'm gonna very quickly test this inside of my browser.
I'll do a refresh here and yep, still got this running.
So now let's try making a change to our server project
and just make sure that the files get synced
and that the server automatically restarts.
So for that, I'll find my server index.js_file.
And to test out a change, maybe let's try to
hard code some value that we're sending back.
So right now, notice how values all,
remember we're trying to
get that information coming from Postgres.
So rather than sending back some information
coming from Postgres, I'm going to instead
comment out the values line
and then send back some hard coded values.
So I'll just say always send 1, 2, 3 like so.
Again, I'm just doing this to have some change
that we can actually detect inside of our application.
So I'll now save this file.
If I flip back over to my terminal
I'll see that Scaffold has seen that we made a change
and synced that file,
and then we can see that node mod inside of our server pods
has automatically restarted.
So now we can flip back over to our browser, do a refresh,
and I'll see, okay
I probably put in the incorrect format of data.
I think that's probably supposed to be an array of arrays.
So my mistake there.
However, if we open up our network request log
and we look at all
we will see that we did receive an array of 1, 2, 3.
So we definitely successfully saw that change sync
to our server and the server automatically restarted.
All right, so now last thing we can do.
Once we're all done with development
we can stop scaffold by hitting control C
and all those different deployments and services
everything automatically get cleaned up after us.
All right, so that's it.
That's pretty much scaffold in a nutshell.
Personally, I use Scaffold on every Kubernetes project
I work on because it makes it incredibly simple
to first off work on different projects
on your local machine.
And it also makes it really easy
and straightforward to do local development environments.
So like work on a React application or an API
without having to constantly rebuild all these images
and manually redeploy them every time as well.
All right, so I hope you enjoyed this
and we'll take a pause right here.
And that's pretty much it for now.
So I'll catch you later.