Deploy Django App to Railway in 5 Minutes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello ladies and gentlemen my name is Destiny and welcome back to my channel so in today's video I'm going to be showing you guys how to easily deploy your application to railway in less than five minutes so if you don't see more videos like this don't make sure to drop a like and start subscribing and also make sure to share this video to someone that might find it useful so without wasting more time let's go ahead and get started in order to go ahead and deploy your app to railway you need three things the first thing that you need is a GitHub account so you need a GitHub account and you also need a railway application account and uh you also need this over here but this does um blog post that I found over here it's not necessary um in case you just want to follow along with some step-by-step guide that's why I'd recommend it so I'll put the link in the description below and uh yeah so if you want to go ahead and deploy up using this it's gonna guide you so the first thing that we're gonna do is go ahead and create a railway account so you want to come over to railway.app then just create an account I'm simply going to get rid of this dashboard URL over here and I want to make sure that I have an active internet connection so I'm just going to connect to the internet now and um after that it's done I want to go ahead and refresh this and let's see hopefully this loads up now okay so as you can see I'm already logged in but by default you won't be logged in so all you need to do is go ahead and sign up a new account it's totally free you don't need the credit card on file to do anything everything is totally free but in order to actually get rid of this limit over here this 467 hours limits you definitely need to put a credit card there but aside from that every other thing is totally free you don't need to put a credit card and right now I don't even have a credit card on file and I'm still working with this so after you've done this the next thing you want to do is go ahead and um create a GitHub account if you don't have one already and for you to be watching this video that's mean if you already have a GitHub account now you want to go ahead and create a new repository and I'm going to come over here and create a new repository and we could just call this let's say News website I'm just going to say news websites maybe using Django using Django something like that and uh yes this is how I want to create it I'm just gonna come down and hit the crates repository that's all we need to do we don't need to do anything here on GitHub again and after this is done you want to go ahead and I'm going to go to my desktop I'm gonna come over to my desktop now and um I'm gonna choose one of the projects that I want to deploy so I've got a couple of projects over here that I want to deploy I could not deploy um The Tick Tock clone using node.js or or Spotify clone using Django or okay I actually want to deploy let me just deploy the news up so I've got this news app over here now what I'm going to do is simply open up this news app in a code editor so I could either open this up in in Sublime Text or you could open it up in let's say Visual Studio code or whatever anyone is going to work perfectly well so after opening all this up I'm just going to go ahead and close out all the stabs that I've got over here I'm going to close this out too and I'm just gonna come over here and I'm going to close this tab out and no I don't want to save the tab so this is what I opened up newly I'm just gonna open up and um in here you need to create three files one of the files is going to be called proc file another one is going to be the requirements.txt and then another one is going to be runtime.txt so all you need to do is come over here if you're on Visual Studio code all you need to do is right click and click on create new file and um we're gonna call this one proc file so I'm going to say proc file and in this proc file as you can see it says proc file already exists do you want to replace it so I don't want to replace it because I already have a file there called proc file now in this proc file it's going to be here it doesn't have any extension take notes just proc then file f-i-l-e and in this proc file I'm going to open up this proc file over here as you can see what we need here is just web then goneicon reporters prj this over here is the name of my project let's say the name of your project is um my project or the name of your project just look for the look for the file where the settings.py where the wsg GI dot py file is sitting and just change just copy whatever folder that's housing all that in my case mine is reporters prj and you want to post it over here so reporters prj.wsgi that's this wsgi over here then you want to just add dash dash log Dash file as easy as that's no strings attached that's what you want to do and you also want to create a new file called requirements.txt so if you are using virtual environments in your application let's say you are building as a Django app and you are using virtual environments what you want to do is going to be easy you don't need to come over here and type out all this what you want to do is just come over to your to your command prompt or whatever you're using it might be git CMD this might be bash or whatever then I simply want to see the introduce project so I'm going to come over to this portfolio project once more and um I'm gonna open up this I'm just going to drag this and drop it in here and take note I already typed out CD so I want to CD into this project I'm gonna hit enter on my keyboard and as you can see I'm there so when I say LS you see I got okay it's dir um I'm not on a Linux now so it it's the IR then as you can see now I've got all these files now if you want to go ahead and see all the packages you have installed and let's let's say you're on a virtual environment all you need to do is say peep freeze and it's going to go ahead and list out all the packages that you've got in the virtual environment take notes but now because I'm not in a virtual environment as you can see it's listing out all the whole packages that I've got installed on my machine so make sure you're in so make sure you are on a virtual environment and everything is going to work fine for you okay so if you want to go ahead and add your requirement to txt automatically what you simply need to do is this you want to say peep freeze so this is going to get all the requirements um the requirements files or the packages that's in your in your machine that's in the virtual environments to be precise then you want to say you want to add an angle bracket a greater than sign then you simply want to call the name of the file it's going to be requirements.txt so I'm purposely adding double s because I already have a file called requirements.txt now when I hit enter on my keyboard doesn't take any time at all as you can see it's just loaded up now when you come over to your project what do you notice we have a new file called requirements.csd and it has all the packages or you can even manually come over here and remove some of those packages and just leave the ones that you used for example I use the lead Django and I used gunny con and that's simply what you need okay so if I come over to this packages make sure that you have gone econ I'm going to list the ones that are required make sure that you have gonna con make sure that you have Pillow that's if you're using any image in your project you want to leave cycle binary for some weird reasons I don't know you could just get rid of it it's your project might still work without it but based for based on the project that I'm I'm working on right now I think I need this and I also use Django targets so that's why I needed this and I also use social share in the project and I also use Django so Django is compulsory you need to have it and for the final for the final up um file that you're going to be needing I'm going to go ahead and delete this one now and for the final file that you're gonna be needing you're going to be needing the runtime txt so create a new file call it runtime.txt and in rawtime.txt you simply need to pass in the python version that is on your local PC okay how do you get the python version all you need to say is simply python dash dash version and what do you notice as you can see python 3.9.1 so you want to say python hyphen 3.9.1 no space okay so if you have the space it might break the code and after that that's pretty much what you want to do about the files then you simply want to come over to the settings.py and you want to add a couple of things over here firstly in the allowed host you want to allow all those hosts okay so just change this to start because we're going to be generating random random domain names and uh you're not going to come you're not going to have the opportunity to come back here and put it in again you can actually do that manually if you want but it's actually speed things up just putting a start over here and everything is going to work fine for you then you want to make sure that all your installed apps are here as usual you already know that and another thing that you'd want to do is this you'd want to um you want to have static routes you also want to have static files directories when you have these two things you are good to go now for the final step you also need a file that's called Static file so you need to get all the static files that you have in your in the projects so you need to get the static files for Railway to be able to render all your static files perfectly well and if you notice if you've used Heroku before or some other platforms like that then you want to add some like white noise to be able to save your static files but you don't need that in real way Railway is so much easier now this is what you want to do you want to come over to your CMD and you simply want to say um python manage.py then you want to pass on this call let's static okay so this is going to go ahead now and collect all the static files what do you notice a new file just laid in here and as you can see we now have 262 static files copied to this directory over here so that's pretty much what you want to do now I want to go ahead and deploy this to GitHub firstly we're going to push it to GitHub so make sure you have a git make sure you have git installed on your PC now I'm going to say Git Version and as you can see I've got version 2. Windows and now the next thing I want to do is go ahead and say git in it so I'm initializing an empty reposition over here to get in it now I need to go ahead and add this so I'm gonna say git add then I want to add all the whole files that means I'm going to give a space after the ad and I'm gonna add a full stop and hit enter on my keyboard so this is going to take a couple minutes or seconds depending on how large your project is and it's going to go ahead and add all the files that we've got to the local report that we are initializing over here and after that the next thing we're going to do is go ahead and come with publishing wait for this to go ahead and finish out everything that it's doing before we start up the next project okay as you can see it's done now the next thing we want to do is go ahead and say git commit gets commits they want to say hyphen M and I'm just gonna pass in um deploying to Hero oh not Heroku deploying to railway I've deployed a lot of apps to Heroku that's why I'm used to Heroku and saying all that kind of stuff so you hit enter on your keyboard and give this a couple SEC it's gonna go ahead and as you can see it's committed all this to the rebel now finally you remember the the repository created on GitHub you want to come over here and you want to copy the Slime this line that will go over here you're gonna copy it and you're gonna get back to your to your command prompt and just paste it over there hit enter on your keyboard and as you can see that's done finally you can go ahead and and say and type out git push hyphen new origin then you call the name of the branch that you want to use so I'm going to say git push hyphen new origin and then what branch that I want to use is um I'm just going to call it master gets push hyphen new origin Master hits and on your keyboard and give this a couple of seconds you go ahead and successfully deploy this to GitHub okay what do you notice everything is done so if you can see done over here that means it's working now we're going to just come over here and refresh and um hopefully this is gonna get deployed okay as you can see it's working over here now and we are done that's all we need to do with GitHub now we're going to come over to railway and um in Railway we simply need to create a new project so I'm going to start a new project and we simply want to deploy from GitHub repo that's it but if you are creating a new account they'd want you to connect your GitHub repo here firstly before you could go ahead and deploy whatever you're building now all you need to do is just hit this button over here deploy from GitHub and GitHub repo so I'm simply going to look for the repo the one that I created and um I think that we call that news live you remember I'm just going to look for that or we could even search it okay this is what can we help you with there is no options on search over there so we're just gonna okay this is it over here so I'm just gonna hit I'm just gonna hit it and I'm finally gonna hit deploy now so that's all we need to do we just need to give this a couple of sec I think a minute or two it's gonna go ahead and run its files and do it thin and it's gonna tell us when our app is up and live so we're gonna give this a couple SEC and I'll be back in a few sets Okay so as you can see it says it's deployed it took two minutes to deploy this as fast as that now what we simply need to do is come over to settings and yours might not already have a domain name all you need to do is just hit generates costume domain or generates domain name whatever but if you want to use a custom domain all you need to do is hit this and type in whatever domain let's say you got a domain from from namecheap or wherever just type it in here and add domain and configure DNS and all that kind of stuff and it's going to work now finally all we need to do is just hit this and I'll give a give it a couple sec and what do you notice it's loading up perfectly well everything is working it took barely five minutes to to configure our app and upload it to railway as easy as that no strings attached nothing more nothing added nothing removed so as you guys can see that's that's pretty much it our site is working perfectly well and and our static files are working perfectly well as you can see let me check out the responsiveness everything is working perfectly well so I think that's going to be it for this video um hopefully you guys enjoyed the video and learned something new and if you want to see some other deployments on other platforms just drop a comment in the comment section below so that's it I hope I'll see you guys in the next video do make sure to drop a like consider subscribing as if you really mean the world to me and yeah for now my love peace out
Info
Channel: Desphixs
Views: 31,552
Rating: undefined out of 5
Keywords: coding, python, desphixs, technology, 2021 tech, programming, java, Desphixs™, Deploy Django App to Railway in 5 Minutes, deploy nodejs to heorku, deploy php to railwawy, deploy asp.net to railway, deploy django, django to pythonanywhere, deply django to aws, deply django 2022, deploy django project, push django project to the cloud, railway hosting, railway hosting tutorial, railway statup
Id: NUqtNglEcCU
Channel Id: undefined
Length: 14min 0sec (840 seconds)
Published: Wed Sep 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.