Moving My Django Website Hosting From Heroku To Railway

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right we are live what's going on everybody so uh as you can see with the title i am going to be moving a website away from heroku to railway and i want to talk about the reasons why i'm doing this and essentially i'm going to take one of my own sites and actually transition the entire site to railway and host it there so i see the chat already active i see some people have some questions so that's kind of what i'm hoping to do here is answer some questions i'm not a railway expert i've just been using them for almost about three to four weeks at this point so i've done research on them and i'll try to answer what i can hopefully everything goes smoothly and i don't bomb this stream so first thing is the fact that or the reason why i'm moving away from railway or from heroku to railway is uh partially because of their free tier plan but also i've been kind of getting uh a little bit annoyed with heroku's changes and so on i still think they're a great company so nothing against heroku i know a lot of people are going to continue using them but i have my reasons for doing that and one of those is the fact that they're moving or they're downgrading their free tier option on november 28th of 2022 so for me that's an issue because i have a lot of students that are i have a lot of students on my youtube courses udemy courses that i'm really heavily relying on for that free tier a lot of people don't have the ability to they don't have the ability to practice and learn with a paid option with heroku so i'm trying to find another free alternative and railway is you know that's not the main reason why i'm moving to railway because it's free that's just something that's nice and uh students are able to to at least get started with them so personally i think heroku's pricing is actually okay but i know that's an issue for a lot of people so that's one of the issues another one was the fact that heroku actually took away their automatic github migrations a couple months ago and then they added them back in so i don't know if that's going to stick around or not but that's kind of a big deal for me to have that and railway just has a lot of options it's a very simple tool so a very simple tool so that's why i really want to switch over and just kind of show everyone what it is so i see a few questions here one of these questions right here right away is uh is it rashawn he's talking about railways free tier uh they did not downgrade from five dollars to two dollars that's actually something you can change in the 500 execution hours which we'll talk about that's something that you can also modify and i'll try to answer those questions as best as i can so let's go ahead and just go over what i'm going to do here so i'll go ahead and move my screen so this is the railway website this is railway.app i have this website this is my personal website right now my domain is actually down just because i messed with the dns configurations uh but this is dennis ivey.com as you can see i have a heroku domain here and this is the site on heroku and i'm really afraid to reveal any uh variables environment variables here so i'm gonna be careful not to show that because i do have a database on aws with passwords and so on there so i would be careful not to reveal any of that so uh here's my heroku account here this is the github repo so essentially with heroku i use github to connect my django uh website to heroku and i'm gonna do the same with the railway we have automatic github uh integration and deployment using that tool so we're just going to go ahead and move this website so first things first let's talk about railway pricing so what i'll do is just go to their website and i'll go to the documentation and i want to talk about that because we already have people asking questions and i'll try to watch the chat as much as i can so if i go into the documentation here we'll go into so we have pricing and plans here so essentially if you just want to look at pricing i won't go over this but this is their pricing structure i think it's very fair and if we go into their plans they have three main plans that i'm seeing so first of all there is a starter plan this is to get started uh you have five dollars of credits every single month and you can use those up so that's where the free tier comes in if you have a pretty small site or a couple of small sites you should be able to stay underneath that so you can use that without having a credit card on file now the issue with this plan here is that you get 500 execution hours every single month so what that means is these are real world hours so let's say i have a service on railway that means every 24 hours i am using up 24 execution hours so if you're trying to host a railway website here let's say you stay under that five dollars right there let's go ahead and calculate that we have 24 times let's say 30 days in a month that's going to be 720 execution hours so it looks like you'll run out of those 500 execution hours in about uh 20 or so days so there's kind of an issue there and at the same time if you have a second service let's say you have an environment and then you have like a database you're gonna get charged for two hours in every real world hour so that means if you have a database and a hosted site that's going to be two real world hours or two hours every real world hour trying to explain that as best as i can so that means you're going to run out of that really quick so that's that first starter plan it's nice just to get started maybe in a tutorial and practice a little bit and this is kind of what you get as far as the offering here but it's not really practical to actually host anything because you will run out every single month now with this next plan we have the developer plan now this one you can actually still use for free so you still get five dollars of execution hours or five dollars every single month credited to your account so the difference with the developer plan is once you verify your account to put a credit card on file you no longer have that 500 execution hour limit so i saw somebody in the chat mention that that goes away so you're no longer worrying about those execution hours you're just worried about usage uh the storage and the actual cpu that you're using in space basically and that's it and you should be able to stay underneath that um i've been testing for the last three weeks or so and i'll just look at my usage and i already do have an account here i think i'm under just for the month of august at 66 cents so i've been hosting a site so that's pretty cheap it's you know it's well under that five dollars i still haven't had to pay for anything so that's what i would recommend doing i know that for those of you that don't have a card on file i'm trying to look for other alternatives here as far as what they have but once you do add a card on file you move up to the developer plan so you upgrade to it not by paying for it by simply just putting a card on file and that means that anything over that five dollars then will get charged to your account and i see praveen's asking about the hackathon i'll mention that a little bit later or maybe just in another video so that's a developer plan and uh here's the offerings you get a lot more space a lot more that comes with it five members to a project and then if you're really looking to upgrade and host pretty big applications they do have a team offering here which really upgrades everything here and then if you need to scale up and up you're able to just contact railway and then they'll adjust to you so that's pricing i just wanted to kind of get that over with and compare that to heroku because i think heroku heroku's uh smallest dino is at seven dollars a month that you have to pay so you're actually doing pretty well here and you do have that free option with railway all right so let's go ahead and just uh get to switching our site we're seven minutes and 15 seconds into this so let's go ahead and take this heroku site and let's move it so right now at this point i don't have to do anything with heroku there's nothing i need to do in the migration all i need to do is go to my railway account here and i'm just going to go to my dashboard so if you're following this video later if it i guess if i don't make any major mistakes i'll keep this video up uh let's go ahead and create an account on railway.app so you want to register for an account and then once you're registered you're going to see this dashboard link here and you're going to see a new project option now when you first start here you're gonna see this alert that says you have two dollars of credits and the or five depending on whether you verified with a github account and then once you add the card on file that will go away so that's why you don't see that here but if i logged in with another railway account you would see this little alert here so don't worry about that so let's just continue here so i said continue really weird there okay so we're going to create a new project we can provision a postgres database a mongodb database we even have these starters here where we can actually go ahead and just provision a django project and it's going to give us an entire template to a django project so we're not going to worry about this one we'll just back up here and we're actually going to restart we'll create a new project and i'm going to do deploy from github so my website is currently on github right here that's how i connected with heroku i already mentioned that so what we're going to do here is we'll just go ahead and go to configure with github and it's going to go ahead and ask me for my github account if you haven't already done this it's just going to walk you through this process i already am connected here i'm just going to need to go ahead and confirm my account here and then go ahead and connect the repo that i want to provision here so we'll just go ahead and select one so i'll just do my personal website i have my personal website somewhere here in fact i think i already have it as available so you'll want to select the website and i was just testing things out here so this is the repo that i want it's already connected so what i can actually do is go back here deploy from github and find that so this is my personal website and i'm just going to do deploy now so it's as simple as that it's actually going into that github repo and it's deploying the site right now so let's go ahead and go into this project so this is the project right here it's initializing it and it's trying to deploy it now we're going to run into some errors because one with django i haven't added in the domain name for the allowed host railway is going to create a domain just like we did with heroku here where you have my name and then heroku app.com so we need to add in that allowed host and then we also need to configure some environment variables because i am going to get that error so right now it's deploying it while we're doing this let's go back into our dashboard so oh that's not done i hope i didn't restart that process no it's not there yet okay so right now it's called web and i see this random name here so what i'm gonna do is just go ahead and modify my environment while that's happening so i'm just gonna go ahead and do uh we'll just do dennis iv.com and again this domain is not going to be live right now just because i messed with the dns configuration so i'm just changing the name here i can actually modify my project name i'm waiting for that deployment let's see these logs here should take about a minute so it's just going through and running through the installed apps just like heroku does where it installs everything from requirements.txt it's trying to provision the website okay so while this is happening i'll just watch the chat here okay actually looks like it deployed no still deploying okay let's give it some time so i see tadas francesco are all in the chat this is partially because heroku won't be free anymore honestly i've been kind of tired of heroku for a while again no i don't want this to be an attack on them because i think they're still a good company i just don't really like using them as much okay so this is my site it's just it just got deployed and this is my domain name so if i go to settings i can actually create a custom domain name if i didn't get this right away i can actually go ahead and have it generate one for me and then i can also add in my own custom domain name so if i want to do this let's say i want veniceiv.com to point to this we'll go ahead and add the domain and i won't work on the dns configuration here but my domain is currently on godaddy so what i would do here is just take these values go to godaddy or maybe you're using namecheap and i would just simply configure that so that's the custom domain but let's go ahead and check out our live url here so it's web dash production and then dash f564.up.railway.app okay so we're getting an issue right now and that's because a few things are not configured here so first of all uh we have these environment variables right here so i have not configured my environment variables what i'm going to do is go ahead and grab them from my heroku account and i'm going to do this off screen and i'm just going to go ahead and add every single environment variable that i have so for example we would see something like db name so this is to my aws rds instance and then would have the url right there would add it and then i can go ahead and add more environment variables and so on so we'll take care of that right now so what i'm going to do here is i'm actually going to hide this so for a second you're just going to have to look at something else here whatever is on screen so i'm just going to leave it right here and i'm going to connect those environment variables so remember in heroku this is inside of settings and then reveal config bars that's where i can open them up and actually see all those variables so i'm going to do that right now so give me one second while i configure all of that and then they're going to be hidden you're going to see the the stars just going to block out the actual environment variables so i'm just gonna make sure you don't see any of that so this is gonna take a minute because i have about six of these so just give me a second here bear with me okay so actually what i'm going to do here is i'm just going to go ahead and hide my screen here so i'm just going to go ahead and remove it so you'll just see my face while i'm doing this so i guess this is the downside of a live stream i can't just do this real quick here or pause it and then edit it okay so i'm just getting my aws access key for my s3 storage that's where i'm storing all my static files we're throwing that in uh then i'm just going to go ahead and grab my aws secret key you'll see these variables in a second just not the actual value okay and if you don't have environment variables then you're not going to have to do this that's something that is very specific to my account but there's a good chance that if you're hosting on heroku you probably have some kind of postgres database or something like that that you'll need to connect to or any other environment variables so as i update each environment variable it's actually going to go ahead and redeploy my site so the changes will happen automatically at least that's what i'm assuming is happening yeah it looks like that's correct so i don't have to try to redeploy it after okay so just bear with me okay and i'm almost done i have about three more environment variables that i'm transferring and you'll see those right now okay give me a second i hate doing this off screen it kind of kills the flow of the stream but i gotta hide my personal information okay so let's go ahead and hide those variables and i'm going to share my screen again so give me a second let's move this over and i'm bringing my screen back into frame okay so what i just did here is i actually took all these environment variables you can see that they're hidden right now but i took my aws access key my aws secret key host database name and so on so i just have these configurations for my personal website and i took all of those from here in this heroku section from my app so i did that now the next thing i need to do is go ahead and configure my allowed host so i'm just going to take this domain right here that railway gave me and i'm just going to go ahead and copy that let's just click on that copy it and then we're just going to move to my github repo and instead of doing this locally what i'm going to do actually here is just go ahead and go into my settings.py file and i'm just going to edit it right here again this is all relative to how you have this configured maybe you're not using heroku or not heroku but maybe you're not using a django website you're using something like node.js that's up to you so whatever you need to do here go ahead and modify that so we're going to take this railway domain and we're going to throw that in here into a loud house i also could just do something like this but it's not recommended where i just do star not recommended for many reasons there but once i do that i'm going to commit those changes and let's go ahead and just see what happens here so if i go back to my railway account we're seeing that another deployment is happening so we're going to give this a second once that's ready my site in theory should be live and then we'll go back to learning more about railway and using their cli tools and checking out the logs there so i'm going to watch the chat here let's see francesco here thank you for being in the chat i think you just did another 12 hour live stream yesterday you're a crazy guy oh by the way i'm actually hosting a hackathon on wednesday at least a day or two from now francesco will be one of the judges there representing daily dev or daily dev whatever they call it i know they wanted to change the name a little bit uh and i'm also adding a django aspect to the hackathon essentially django students who have been a student of one of my courses lately or within the last two years or so all you need to do is submit a receipt to one of my courses and submit a project and you will have a chance to enter 1000 or win 1 000 so i'm gonna make an announcement for that i already did that in my youtube community post so go ahead and check that out there's a link for that if you want to win a thousand dollars as a django student so i specifically tailored it to students and uh not professional developers so people have a chance i don't want people that are really good at this competing with people that are just learning okay so we'll give that a minute still deploying get a chance to drink my coffee let's see spoilers here railways faster and work on the free tier yeah it seems like it let's i'm going to say that right now i can't vouch for anything yet so okay if i go here i have to use that domain that they gave me so we're just going to go ahead and use this one and here we go this is my site it's hosted on railway.app what i'm going to do is post that in the chat if you want to check it out that is the site that's how simple it was so we started off about seven or at seven minutes that took about 10 minutes to do while still waiting for all that that's all you have to do it was really that easy you just simply connect to the github repo you deploy that generate your domain and in this case i had to update my allowed host some environment variables so that really took up most of the time but that's as simple as it was uh really easy to do so right now if i make any changes to github those automatic deployments are gonna happen so let's go ahead and talk about railway and that's it for the actual tutorial part of the video i want to answer some questions and uh see what we can learn so i want to try to go into as much as i can i see matt sichterman sorry matt by the way i got your name wrong last time i said something completely different good to see you in the chat so um right now i'm going to go into the railway documentation so they do have their cli here there's different ways you can actually use railway so i highly recommend checking out their documentation they're definitely a newer company so they're modifying quite a bit here but if we go into their cli they also have a cli tool like heroku does uh railway is really easy to install if you're using npm you literally just run this command here so to use a cli tool i'll just go ahead and do this from scratch here we'll just go ahead and cd into my desktop here i'll zoom in and we're just going to do npm i g at railway cli so this is what's going to install my railway cli it's really easy to use so once i do this this is just going to give me more functionality and more capabilities of work with my project without having to just work from their interface so once i have this cli tool installed i can just go ahead and actually go into railway so i'll do railway login and this is how you log into the railway account so right away it's just going to go ahead and say enter any number so just press enter or hit something on the keyboard and this is going to log me in so i can close this out and i am now logged into my railway account so there's a few commands that i actually saved for this and uh let me just pull some of these up here so we'll just do a railway list and this should pull up all my environment so it looks like it created an environment called accidental punishment it's funny always randomly generates these names so i'm actually going to change that environment name right now so we'll go into my railway account and let's go back into my dashboard let's refresh it because i should be able to see that so this is the environment name so we'll go back in here and i just want to modify this so i can go into settings and we'll just change this to uh dennis website so we'll change the environment name to that so we have a project id which i'll probably actually hide because that probably shouldn't be open not sure how dangerous that is but i'll just make sure to delete this environment after the video so we have that i updated it and now if i do railway list i might have to re-log in okay so there is my environment so uh let me try to remember a few commands here i just need to pull up some of these shortcuts so first of all if i want to go ahead and check out my logs i can actually do railway logs and this will one second uh this will just uh go ahead and let me know what's going on in my logs here so right away i see a failed deployment which i did not see at first my wife just threw my rabbit into the room oh he just went away so that's anyways it's a little distraction here okay so where was i okay the railway logs here okay so let me just figure out what i was doing here so we'll go back into my railway account got completely distracted and i'm just gonna go into the logs here and i don't see any issues so i don't know why it's showing that it's telling me everything went correctly but that's how you can see your logs just by doing railway logs okay so let me try to find a few more commands here so uh if i want to get some help here so we'll do railway help and this is going to tell me all the commands that i have so i can create a new project connect to a database delete projects i can actually link up to projects push projects and so on so let's do railway list i think that's the one i wanted to or was that the first command i ran yeah i already ran that anyway so that's kind of the idea here is you can connect to the railway cli i'll make some other videos on that right now i'm a little bit fresh with it and i'm facing a distraction so uh let's go ahead and just answer some questions go into the chat i'll see if anything else comes up and i'll try to um just get everyone introduced to this so let me pull up the sidebar here all right so you need to connect to a project first uh yeah i just see people talking i want to see what's for me here make a video on aws rds pricing model so you can actually deploy databases with the railway so if somebody wants to see how simple that is we won't go into databases but what i'll do here is i'll go into my dashboard and let's say i want to provision a new django project from scratch so i don't want to have to take a project that i already have built i just want to create a completely new one so what i could do is go into my environment and i'm just going to go ahead and do new and i'm just going to grab a starter here so we'll grab a starter and i could actually go into django i'll just look it up i have a bunch of different starters i should be able to go to django okay i thought i saw django here maybe it wasn't a starter let's try that one more time you know empty spaces databases so provisional postgres database very easy just like that right there uh let me try to create a completely new environment maybe that would be of help here so deploy starter i know for okay here we go so i see django here so if i go to django this is actually going to provision a completely new django environment for me here so it's going to go ahead and create that for me this is the name django.pie repo name is not available let's just throw in one secret key let's just do django secret key generator look that up we'll grab a random secret key once this uh finally works apparently my computer's being slow okay so i'm going to close out the heroku account i don't need the heroku domain anymore and i'll just point that live domain to the railway up here i just lose service i'm still live for some reason that website's not working so it's just asking me to configure that i'll make this a private repository so i don't want that to be public all right so we're going to generate a secret key this is my secret key we copy that we'll throw that into our secret key section here we'll do deploy and that's going to take a second what it's going to do is it's actually going to connect to my github repo or my github account it's going to generate a new project for me and then it's going to deploy it so it gives it a name right here that's the environment name it's creating that and if i go into my github account here let's go into my github account and then we'll go into repositories so this is that new project django pi one it just created this and this is gonna give me a boilerplate django project so railway just generated all this you can see that 17 seconds ago very easy to do this and uh just gives me some information about that project itself so i see francesco's leaving it's good to have you here take care francesco okay so that's deploying it's going to take about maybe 30 more seconds we'll let that finish up we'll view this and then i'll go into the chat here so all right looks like a lot of people are just communicating with each other railway does have a free tier to give you five dollars five dollars every single month if you add a credit card on file uh that's going to be the better version of that free tier okay so let's see cool so i don't see too many questions go ahead and ask those questions because once this is deployed uh we will end the stream and uh well that'll be it for today so this is my new django project i can click on that live link and this is my django app what i could do is just go ahead and clone it locally and start working on it and get things going so what it does for me is it automatically creates an account for me or creates a django project it goes ahead and creates an app for me it connects that app and it even connects all the urls here so if we look at urls.py it already creates a default view for me which is really nice you can go ahead and get started and it takes a couple of seconds to do that and that's the application that railway gives me okay so someone's saying hello dennis just joined from south africa good to have you alfred here awesome okay i think we are good i do have another video on railway deploying a postgres database uh that also is very quick and easy to do and i'm probably going to take my personal database from aws and actually move that to railway because they make that very easy so that's it for this stream didn't want this to go on too long this video will be posted uh it will be posted and it will be on my channel so i'll leave it there and all right that's gonna be it see you all later
Info
Channel: Dennis Ivy
Views: 44,107
Rating: undefined out of 5
Keywords:
Id: do0otUW7454
Channel Id: undefined
Length: 27min 8sec (1628 seconds)
Published: Mon Aug 29 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.