Playing
03. Deploying to Forge

Transcript

00:00
So if you're new to working with Forge or you just need a refresher, let's go ahead and get this application deployed now.
00:05
So if you have pulled this project down locally, go ahead and push this to your own repository, which is connected up in Forge. And that means that you can go ahead and deploy this straight from GitHub.
00:16
Let's go over to our servers overview over in Forge and go ahead and create our server with any of the providers that we want. For this to work, we just need a standard app server here. Let's go ahead and just call this reverb.
00:28
And we can choose any of these server sizes we want. Let's just choose the most basic here. I'm going to go ahead and switch the region over, although this doesn't really matter.
00:37
And let's go ahead and create this server out now. OK, you can go ahead and copy the pseudo password and database password if you need them. I don't need them for the purpose of this
00:46
because we're not going to need to SSH into anything. So let's go ahead and just close this off. OK, so all that we need to do now is just wait for this server to provision. And then we can go ahead and get this app deployed on a domain.
00:59
Once your server has been provisioned, let's go ahead and add a new site and get rid of the default site. We need this running on a domain. That's really, really important.
01:09
So the domain that I'm using is my personal domain, alex.gs. But of course, replace this out with any of the other domains that you're working on. And we can just click add site here. Let's go over to our site section and let's get rid of this default site.
01:25
We're not going to need that. So we can just choose delete. And let's go ahead and type that in and hit confirm. OK, so now that we've got this site, we're going to go over to here
01:34
and we're going to deploy this application using the GitHub repository. Of course, if you haven't already pushed this to your own GitHub account, go ahead and do that now if you're following along. So we want to go ahead and deploy a co-course slash
01:45
and we want to grab the name of this and just pop that in there. And we want to deploy the main branch. OK, for the database, we are going to choose forge or just leave this. It doesn't really matter.
01:56
And let's go ahead and hit install repository. Once your repository has been installed, let's head over to the deployments tab and update our deploy script to run npm install and npm run build. This is really important.
02:09
So we can, of course, install our dependencies and build our assets. So we're going to hit update on that. We'll be coming back to this later because when we do set up reverb, it's going to add a restart command to this.
02:22
OK, let's go ahead and deploy our application. It's not going to work just yet, but let's at least get the files copied over to our server. OK, once that's been deployed,
02:31
we're actually going to need to hook this up to our domain name. So I'm using Alex.js, which at the moment doesn't point anywhere. So wherever you're managing your DNS, you're going to need to head over here and add an A record.
02:43
So let's go and add a record in here. We're going to add this A and at, and we're going to point this to the IP address of our server and we're going to hit save.
02:53
I'm not going to proxy this through Cloudflare just yet, but you can do that if you want to. OK, so once our A record has been added, unfortunately, we're just going to need to wait for this to properly propagate.
03:03
And then once this does happen, we should be able to reach our site at this domain. OK, it looks like the DNS is propagated and we can now access the site. We can go ahead and register,
03:13
get onto our dashboard and make sure that we can see everything. Now, at the moment, this probably isn't going to work. The reason being is that we are using SQLite and we don't have that file that exists on the server.
03:25
So we can actually come over to the command section here and we can run a command. So let's go ahead and run touch database slash database SQLite and that will go ahead and create that for us. Let's hit run and just wait for this to finish.
03:38
Once that's done, we should be able to head over now and register an account. So let's make sure we can get on the dashboard. Of course, our real time functionality will not be working at the moment, but that's what we're covering through the rest of the course.
03:51
OK, great. So we are now into our application. When we hit this, of course, nothing happens. Let's cover how to get reverb working on Laravel Forge throughout the rest of the course.

Episode summary

In this episode, we walk through the entire process of getting your Laravel application live on Laravel Forge. Whether you're totally new to Forge or just need a quick refresher, we cover everything you need to know to get up and running.

Here's how it goes: we start off by setting up a new server in Forge, picking our preferred provider and region (no worries, any basic setup is fine for this). Then, we walk through connecting your repo—making sure your project is pushed to GitHub and that Forge can access it. Once the server is provisioned, we add our domain, clear out the default site, and set up our new one.

Next, we handle the deployment: linking your repo, setting which branch to use, and making sure the deployment script includes npm install and npm run build so your assets are compiled. We then go over pointing your domain to your new server by adding an A record (and a note about DNS propagation).

Once the deploy is done and DNS is sorted, we check out the app in the browser. We troubleshoot a quick issue with SQLite by manually creating the database file on the server. Finally, we confirm the app is working, and mention what's coming next—specifically, setting up the real-time stuff with Laravel Reverb in later episodes.

So by the end, you've got your app running live on a custom domain via Forge, and you're ready to rock with the next parts of the course!

Episode discussion

No comments, yet. Be the first!