R
Railway•6mo ago
Monster

deploy react+fastapi+postgresql+celery on railway

Hi, I have a github repo composed of fastapi as backend, and react as the frontend, and the postgreSQL as DB, all of them are dockerized, all of the dockers are configured to be running on local machine perfectly. now I am trying to deploy the full stack on railway, but I did not find much information to guide me through. my friend recommended me to railway instead of aws, it supposed to be straightforward to deploy such a typical stack. I am confused, am I misunderstood the way how railway is supposed to be used.
53 Replies
Percy
Percy•6mo ago
Project ID: N/A
Brody
Brody•6mo ago
as simple as railway can be there is always going to be a learning curve, and that's what me and the rest of the community are here for! I would love to help and you gave a decent bit of information, but for me to help you to the best of my abilities I would need to see exactly what you are working with, so please share your repo.
Monster
MonsterOP•6mo ago
GitHub
GitHub - tianerphil/full-stack-fastapi-template: Full stack, modern...
Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more. - tianerphil/full-stack-fastapi-template
Monster
MonsterOP•6mo ago
it is a just a test repo, doing nothing, just to try the deployment process of this type of stack. I have tried to use railway cli to deploy to railway project id is 7c880d15-5696-4b26-8e79-fa845c36b0b5 but encounter some error, seems like I need to do some customization to the dockerfiles.
Brody
Brody•6mo ago
so just to make things clear, railway does not support docker compose just wanna get that out of the way before we jump into this can you show me a screenshot of your railway project?
Monster
MonsterOP•6mo ago
hi, sorry I was offline earlier. the screenshot is here, it does nothing but a empty fastapi framework, with simple postgresql db holding the book information.
Monster
MonsterOP•6mo ago
No description
Monster
MonsterOP•6mo ago
this is the screenshot running local dockers.
Monster
MonsterOP•6mo ago
and this one is the one I tried to deploy to railway. I have installed railway cli, and used railway init, and railway up
No description
Monster
MonsterOP•6mo ago
just for your information if it may matter in some way, the final deployment will be a image generation service, I will deploy fastapi backend and react frontend here in railway, the backend will fetch the generation from runpod gpu serverless, store the metadata in postgresql hosted here in railway, all the tasks will be managed by redis and celery which will also host here in railway. does that make any sense to you from the railway point of view?
Brody
Brody•5mo ago
yes your docker compose file states you are using postgres 12, does it need to be an older version? would postgres 16 work? sorry for the late reply, I was asleep
Monster
MonsterOP•5mo ago
haha, I do not have a strict version requirement on the postgresql. at this very initial stage I'd rather to grab some main idea about the deployment process, and the spacific customization needed to ship the local docker orchestration to the railway platform. any guide or blog available? thx. no worry at all, sleepping is good hobby haha
Brody
Brody•5mo ago
there is no good way to deploy a docker compose file to railway, you need to manually reconstruct services in your railway project, id be happy to try my best to walk you though it
Monster
MonsterOP•5mo ago
ok thanks, how can we start?
Brody
Brody•5mo ago
deploy postgres into your project from the create button on your project canvas
Monster
MonsterOP•5mo ago
deployed
Brody
Brody•5mo ago
please send a screenshot of your project canvas every time you make a change just so that i can follow along and make sure things are going smoothly
Monster
MonsterOP•5mo ago
No description
Brody
Brody•5mo ago
did you delete the fastapi service? where did it go?
Monster
MonsterOP•5mo ago
I created a new, should I delete the previous project?
Brody
Brody•5mo ago
yeah delete the old project, we want everything inside of one project
Monster
MonsterOP•5mo ago
deleted
No description
Brody
Brody•5mo ago
open that project and change the project name to something more suitable
Monster
MonsterOP•5mo ago
done
Brody
Brody•5mo ago
please remeber the screenshots
Monster
MonsterOP•5mo ago
No description
Brody
Brody•5mo ago
okay create a new empty service, name it properly as the backend, and configure any service variables it will need
Monster
MonsterOP•5mo ago
yes, I am doing. do we have to create empty service and configure all the stuff again, or can we create a docker image and pull my configured docker image for the backend and frontend is that more straightforward
Brody
Brody•5mo ago
pull from where?
Monster
MonsterOP•5mo ago
docker hub
Brody
Brody•5mo ago
is it a public image?
Monster
MonsterOP•5mo ago
I can set it to public
Brody
Brody•5mo ago
then yes, you can have the service pull the public image, but you still need to set service variables so please go ahead and do this
Monster
MonsterOP•5mo ago
it is a little bit late here, I cannot stay long as tomorrow need to drive 300km. do you have some blog or instruction for similar deployment that I can follow. I am brand new, do not want to keep you long.
Brody
Brody•5mo ago
damn thats a long drive, but no theres no blog or guide, i am the guide 🙂 so please dont worry about keeping me long, if i wasnt willing to help i wouldnt be helping you lol
Monster
MonsterOP•5mo ago
thank you you are really generous. I will not be able to finish all today. let me do some homework before I ping you for your guidance again tomorrow. in general, can I understand the process like this: I have 5 dockers, db, frontend, backend, and adminer, and the traefic dockers. I can create docker image in railway one by one and pull the configured docker from docker hub respectively. configure the env variables required. and then do some railway specific setting about the reverse proxy and domain setup. is that so?
Brody
Brody•5mo ago
basically yes, but treafik is not going to work on railway, there is no way to do labels
Monster
MonsterOP•5mo ago
ok, so there will be some railway specific reverse proxy service setup.
Brody
Brody•5mo ago
not really, you will have to redo the proxy with something better, like caddy
Monster
MonsterOP•5mo ago
ok. sounds like you bring me out of comfort zone
Brody
Brody•5mo ago
but maybe you wont even need any reverse proxy, can you tell me why you had one to begin with?
Monster
MonsterOP•5mo ago
I mean as a edge router, accepting the main request load, load balancer, ssl termination, internal service routing, middleware setup somthing like that. no special
Brody
Brody•5mo ago
so at this point you understand that you will need a railway service for the frontend (react) and another service for the backend (fastapi), correct?
Monster
MonsterOP•5mo ago
yes is railway designed for frontend deployment or should I only put backend here and deploy frontend somewhere else
Brody
Brody•5mo ago
you have designed your own deployment, you use nginx to serve the frontend, so you are good to go are you aware that railway handles ssl for you?
Monster
MonsterOP•5mo ago
so solely nginx is enough for serving the frontend, no need traefic any more?
Brody
Brody•5mo ago
correct on the frontend railway service you would set domain.com and on the backend service you would set api.domain.com and have your frontend simply make requests to the api.domain.com domain
Monster
MonsterOP•5mo ago
ok, sounds like straightforward.
Brody
Brody•5mo ago
feel free to ping when you have more time to jump back into this
Monster
MonsterOP•5mo ago
I feel railway is designed primarily for backend, is that true. should I put frontend to some where else?
Brody
Brody•5mo ago
railway is what you make of it, your frontend service uses nginx so serve the static files so you are set to deploy a frontend on railway without issues
Monster
MonsterOP•5mo ago
ok, got it. thx. good night / good day. appreciate your kindly help
Brody
Brody•5mo ago
you too!
Want results from more Discord servers?
Add your server