Deploying Django Back End & React Front End

dvdmncTRIAL

a year ago

Hello
I'm having trouble finding information about deploying Django REST backend and React front end on Railway.
Could someone shed some light on this for me?
Thank you

0 Replies

dvdmncTRIAL

a year ago

django js


dvdmncTRIAL

a year ago

so python js html css


a year ago

okay, go into that service and remove the custom domain


a year ago

then delete the entire service


a year ago

then create a new project, with an applicable name "My Portfolio"
and an empty service within that project, name it as well
then add your custom domain to it, setting up the cname as needed
then deploy your code to it


dvdmncTRIAL

a year ago

Ok, can we just do that later ? Because i'll have to connect to cloudflare, i don't remember exactly what i did to set up the proxy so it's maybe going to take a while


dvdmncTRIAL

a year ago

the proxy for the custom domain name


dvdmncTRIAL

a year ago

and use the empty service i created with the variables


a year ago

sure we can do that later, for now we will ignore the portfolio service


dvdmncTRIAL

a year ago

ok cool


a year ago

did you have a custom domain for this new app? or where you just going to use the railway provided domain for now?


dvdmncTRIAL

a year ago

no because i have to see with my client for the custom domain so i was just going to use the railway domain


a year ago

gotcha


a year ago

okay go and generate a domain, this will be the backend's domain so name the subdomain applicably


dvdmncTRIAL

a year ago


a year ago

what do you have in mind for the frontend railway domain?


dvdmncTRIAL

a year ago

musiquizapp.fr for the custom domain name


dvdmncTRIAL

a year ago


a year ago

thats a custom domain? you said you didnt have one yet


a year ago

ah gotcha


a year ago

okay the service now has that domain?


dvdmncTRIAL

a year ago

yep


a year ago

did you commmit the railway.json to the repo?


dvdmncTRIAL

a year ago

now yes haha


a year ago

okay in the service settings, set the root directory to /Back-End


dvdmncTRIAL

a year ago

done


a year ago

add the repo to the service


dvdmncTRIAL

a year ago

ok just one thing tho. In media, i wasn't able to download all the audio files that are needed for the game. For now they are on the media file on my computer. Will we be able to bundle them with all the other files for the deployment ?


a year ago

how much audio do you have size wise?


dvdmncTRIAL

a year ago

569 Mo


a year ago

is this dmca free audio or do you have the rights to it?


dvdmncTRIAL

a year ago

Don't think they are dmca free, these are all old songs from french singers


a year ago

doesnt sound like something you should be uploading to github then, especially when the repo is being deployed to railway.
look into a cdn you can upload the media to, but thats slightly out of the scope of this thread


dvdmncTRIAL

a year ago

what if i use the cli in vs code to deploy the project ? The files are in the folder. That's what i did for my portfolio but only had images


a year ago

railway does not want you uploading/playing/using music you dont have the rights to, thats why music bots are a big no no and often get people banned


a year ago

id strongly recommend you host the music elsewhere on a cdn, just dont want you getting banned


a year ago

thats also far more data than you can railway up to the service (max 40 or 50mb i forget the exact number)


dvdmncTRIAL

a year ago

Ok so like if i host the samples on soundcloud for example, then i'll just have to modify their address on the db and it'll be good to go


a year ago

sounds about right, dont know if soundcloud would like that, but as long as its not on railway im good with it


dvdmncTRIAL

a year ago

Ok i'm in the phone with my client to see how we're going to do it


a year ago

sounds good, but in the mean time, would your backend fail to deploy without those audio files?


dvdmncTRIAL

a year ago

Sorry i just finished the call


dvdmncTRIAL

a year ago

Yes i think so


a year ago

okay are you gonna update your code and then after that continue with the railway deployment?


dvdmncTRIAL

a year ago

He said that he will download the songs on soundcloud but doesn't know when. So i think i'll wait until he's done it to continue. I'll send you a DM, is it ok for you ?


a year ago

we can continue this thread when you are ready


a year ago

you can ping me here


dvdmncTRIAL

a year ago

Alright cool thank you brody


a year ago

no problem!


dvdmncTRIAL

a year ago

Hey Brody, the music is hosted on a CDN, we can continue if that's ok for you !


a year ago

haha sure, but unfortunately im not available right now due to some irl stuff


dvdmncTRIAL

a year ago

Sure nothing's urgent, just ping me when you're ready !


dvdmncTRIAL

a year ago

Hello Brody, are you free now ?


a year ago

I am now


a year ago

where did we leave off


a year ago

hey @Dadz did you still need help with this?


dvdmncTRIAL

a year ago

Hey Brody, yes i do, don't know why i didn't receive the notification of your answer


a year ago

no worries


a year ago

lets pick up where we left off


a year ago

did you share your github repo with me?


dvdmncTRIAL

a year ago

Yes i did


dvdmncTRIAL

a year ago

I tried to deploy, i was missing pillow and python-dotenv in requirements.txt, i'm currently trying to deploy again


dvdmncTRIAL

a year ago

But it's taking way too long something's wrong


a year ago

haha okay let's slow down a bit


a year ago

let me get caught up before we try things again


a year ago

can I have a screenshot of your railway project canvas


dvdmncTRIAL

a year ago

1220390190712099000
1220390190942523400
1220390191190114600
1220390191462879200


a year ago

haha every screenshot but none of them are the project canvas


dvdmncTRIAL

a year ago

1220391403952275500


dvdmncTRIAL

a year ago

Back End is deployed and seems to be working



a year ago

going forward these cropped screenshots are not the best, can you please send full screenshots of the browsers viewport, I can always zoom in if I need to


a year ago

for all I know you could very well have a 3rd service off the to the left of those two


dvdmncTRIAL

a year ago

Ok i didn't think the other services would matter as they don't link to MusiQuiz. Here you have the full screen

1220395951315882000


a year ago

every little bit of information matters


dvdmncTRIAL

a year ago

We discussed about the fact that i had the database for MusiQuiz set up in my portfolio project (a mistake) and decided to keep it that way because the db had data so it would have been better to move the portfolio but as i have a private domain name with cloudflare as a proxy it would take too much time to remove the custom domain


a year ago

okay so would you be interested in adding me to both of your railway projects (for the portfolio and music quiz) and your github repo for music quiz? that way i can make all the changes needed without the back and forth


dvdmncTRIAL

a year ago

The thing is i would like to understand the changes so that i'll be able to deploy this type of configuration by myself in the future


a year ago

fair enough


a year ago

then we shall walk through it


dvdmncTRIAL

a year ago

Sorry for the late response


a year ago

so what was the situation with the database again?, does both your portfolio and musicquiz app have data on that same database?


dvdmncTRIAL

a year ago

No only MusiQuiz


a year ago

can we remove the music quiz service from the project then? and start fresh in a new project


dvdmncTRIAL

a year ago

Yes sure


dvdmncTRIAL

a year ago

Without moving the database then ?


a year ago

well you said the database is only used by the portfolio, so you dont need to touch it and it can stay in that project


dvdmncTRIAL

a year ago

No when you asked me i said that only MusiQuiz has data in that database


a year ago

oops, my bad


dvdmncTRIAL

a year ago

haha no worries


a year ago

so we can move the portfolio to another project, since its easier to move an app service than it is to move a database


dvdmncTRIAL

a year ago

Yes that is what you told me last time we talked but remember i asked you if this was necessary as moving the portfolio project would require to remove the custom domain and i didn't remember what i did exactly to set up the proxy so it would maybe take a while. You told me then let's ignore the portfolio service


a year ago

you wouldnt actually need to do any dns setup given the fact that you have already done the dns setup once


a year ago

just remove the domain from old service and then add it to the new service, and it will work instantly with zero dns setup, at least it always has for me


dvdmncTRIAL

a year ago

Ok that's done but i get Internal Server Error for the first version of the portfolio


dvdmncTRIAL

a year ago

The V2 with the custom domain is working fine


a year ago

check its logs?


dvdmncTRIAL

a year ago

I forgot the Secret Key in the variables


dvdmncTRIAL

a year ago

It's all good now


a year ago

okay now you can remove the domain from the old service and then add it to the new service, ignore any dns setup as it is not needed


dvdmncTRIAL

a year ago

Yes it's done


a year ago

okay now you can remove those two old services and rename the project


dvdmncTRIAL

a year ago

Just had to change the CNAME on cloudflare


dvdmncTRIAL

a year ago

Done also


a year ago

you didnt


dvdmncTRIAL

a year ago

What ?


a year ago

ignore any dns setup as it is not needed


a year ago

it will work instantly with zero dns setup


dvdmncTRIAL

a year ago

Railway asked me to copy a variable and to add it as a cname


dvdmncTRIAL

a year ago

I had to do that also when i changed from V1 to V2


dvdmncTRIAL

a year ago

And it's working fine


a year ago

yes, but it wasn’t strictly needed, no harm either way though


dvdmncTRIAL

a year ago

Ah ok


a year ago

i was just trying to simplify the process for you by telling you it wasnt needed


dvdmncTRIAL

a year ago

Ok thanks


a year ago

can i have a screenshot of the project now?


dvdmncTRIAL

a year ago

1220443981977092000


a year ago

perfect


a year ago

rename that service to MusiQuiz - Frontend since it will be the frontend service


a year ago

and then add a new empty service that is named MusiQuiz - Backend you get the point 😉


dvdmncTRIAL

a year ago

This is the back end


dvdmncTRIAL

a year ago

But yes i get the point haha


a year ago

the domain name would suggest otherwise


a year ago

frontend domain -> [musiquizapp.up.railway.app](musiquizapp.up.railway.app)
backend domain -> api-[musiquizapp.up.railway.app](musiquizapp.up.railway.app)
at least until you add your custom domains


dvdmncTRIAL

a year ago

Ok


a year ago

let me know when you have that done!


dvdmncTRIAL

a year ago

I'm solving a lot of issues since my last message haha, serving of static files for django rest, fetching the right api, chunks of code i forgot to push on my git hub repo, and now i'm struggling on Django Admin Panel CSRF token validation


a year ago

okay no worries, let me know when you are ready to proceed, just make sure you arent trying to get django to serve the frontend


dvdmncTRIAL

a year ago

The app is up and running !


dvdmncTRIAL

a year ago

Thanks for your help Brody


a year ago

you have your frontend and backend running as seprate services?


dvdmncTRIAL

a year ago

Yes


a year ago

what have you done to not run your frontend as a dev server?


dvdmncTRIAL

a year ago

i didn't do anything


a year ago

then you are likely running a development server for your frontend


a year ago

thats going to cause random issues and cost a lot when running on railway


dvdmncTRIAL

a year ago

Oh yes i just saw the metrics


dvdmncTRIAL

a year ago

😂


dvdmncTRIAL

a year ago

Then i guess we're not done yet


a year ago

https://github.com/brody192/vite-react-template

Copy the nixpacks.toml and Caddyfile from this repo into your frontend folder.

If you have any build or start commands set in the frontend's service settings, please remove them.


dvdmncTRIAL

a year ago

done


a year ago

and let me know if there any issues with the new deployment


dvdmncTRIAL

a year ago


a year ago

full build logs please


dvdmncTRIAL

a year ago


a year ago

can you link your repo again?


a year ago

why do you now have two seprate repos?


dvdmncTRIAL

a year ago

Because i was confused so i separated the back and front in two separate repos


dvdmncTRIAL

a year ago

But now that i understand how it works i could merge them


dvdmncTRIAL

a year ago

Does this have anything to do with the deployment problem?


a year ago

oh i see what i did wrong


a year ago

i linked you the wrong repo


a year ago

use the nixpacks.toml and Caddyfile from this repo instead


dvdmncTRIAL

a year ago

Yes it's working but it still taking the same memory space


a year ago

show me the source settings you have on your frontend service please


dvdmncTRIAL

a year ago

What do you mean the source settings ?


dvdmncTRIAL

a year ago

the package-json ?


a year ago

in your railway service


dvdmncTRIAL

a year ago

1220503273572929500


dvdmncTRIAL

a year ago

That's all i have in the source settings


a year ago

i dont even know how thats working


a year ago

set the root directory to /Front-End/musiquizapp/


dvdmncTRIAL

a year ago

Yep memory is low now


dvdmncTRIAL

a year ago

do you know why ?


a year ago

wrong directory


dvdmncTRIAL

a year ago

Ok, we're all set ?


a year ago

i think so haha


dvdmncTRIAL

a year ago

Ok perfect thank you again Brody


a year ago

happy to help