7 days of WordPress plugins, themes & templates - for free!* Unlimited asset downloads! Start 7-Day Free Trial

Next lesson playing in 5 seconds

  • Overview
  • Transcript

2.3 Deploy the Application

Now that our application is ready, we can safely deploy it to the cloud. In this lesson, you'll learn how a couple of commands in the command line can quickly spawn a Heroku container and run your application within it.

2.3 Deploy the Application

In the previous lesson, we were left with the production environment on the database file. We have the adapter specified with some settings along the remaining of the configuration. We don't have any username or password combo. Remember that, because Heroku will take care of that for us. The next step is to actually deploy the application, everything that we've been hoping for. So I'm gonna leave the editor and I want you to consider these little symbols that I have right here. If I type in git status, you will see that we have some changes. We haven't committed those. It's very important that you know how to use git in order to the ploy to the server. So these little symbols, these are just a sample of mine. You can check my.files around ZSH, I'll post a link below in the description. So as I was saying, we have some changes and a new file. We'll need to add in those into the deploy. So we'll add those in, type in git add then dot to just add all of the changes and now we can commit. I'm going to say, for example, prepare for first deploy. I'm using a C shorthand, because I have that in my configurations, but you should type in git commit with dash m. So now that I have this commit, I am ready to perform my deploy. If you check git remote -v, this will give all of the information around our remote repositories. You can see we have the Tuts+ repository from GitHub, the one we fetched the code from and then the Heroku repository, which will basically allow us to deploy the application in there. So for this to happen, we need to type in git push and then heroku, which is the name of the repository and then master. We want the master branch, so there's that. Once you do it, you will see the git repository being updated and a hook in the other side on Heroku will be triggered. It will detect a Rails app with the correct reversion, all the dependencies and it will basically start booting up your app. It will bundle all the dependencies, including the production environment settings and so we just need to wait and see what Heroku is telling us. If we forgot something, Heroku will tell us right down below. So let's just wait a bit. Notice this step in particular as Rails will actually precompile the assets into its own folder. So everything that's done live in development and will be run only once in production and all the CSS files and JavaScript files will be there. Well, there you go. The deploy is actually running. So great job. You can see that it's actually launching the application and then the URL is shown to us. So basically, you type in this address into the browser and it should load. However, we're still not going to, because we still need to migrate the database. The way we do it is by typing heroku run and this will run a command in our application, in our server. I'll type in rake tb:migrate and this will take care of the database changes. So do that and you'll see some information being printed out. Just wait a little bit and there you go. All of the changes are there. So all the commits, all of the table instructions to create the table, definition, the constraints. All of it is right here. Let's see if everything is okay. Let's type in heroku ps and this will list all the processes in our application, the web server. You can see here that the Rail server is actually being run. So good job. Now let's see by going to the processor, let's type in tutsplus-projekt2.herokuapp.com. Let's type that in, just wait a little bit until the application puts up from the code and there you go. A couple of seconds later, you will see our application. Effectively, it is trying to reach to all the projects, but we still don't have any. Let's create a new one. Let's, for example, create My First Project, let's type something like "Hello! The project will end on August 20. Let's just create a project, and there you go, the project is right there. Also, noticed that the assets are being properly loaded. Because otherwise, we're wouldn't have this layout with a side bar on the right and this font as well. If we check the source really quick, you will see the assets folder with the respective CSS and JavaScript files. If I click on one of those, you will see everything being collapsed. Basically, all of our code is in here. So good job. The same goes for the java script file. So just click on that and you will see that jQuery functions and all that good stuff. So congratulations on your first deploy. It really is interesting to see all this done with a simple Git commit. All you need to do is focus on specific details on your application just to fit with the Heroku production environment and you'll be good to go.

Back to the top