deploy react+fastapi+postgresql+celery on railway

Anonymous
TRIAL

a year ago

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.

0 Replies

a year 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.


a year ago

n/a


Anonymous
TRIAL

a year ago


Anonymous
TRIAL

a year ago

it is a just a test repo, doing nothing, just to try the deployment process of this type of stack.


Anonymous
TRIAL

a year ago

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.


a year ago

so just to make things clear, railway does not support docker compose


a year ago

just wanna get that out of the way before we jump into this


a year ago

can you show me a screenshot of your railway project?


Anonymous
TRIAL

a year 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.


Anonymous
TRIAL

a year ago

1254674828791906300


Anonymous
TRIAL

a year ago

this is the screenshot running local dockers.


Anonymous
TRIAL

a year 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

1254675389561700400


Anonymous
TRIAL

a year 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.


Anonymous
TRIAL

a year ago

does that make any sense to you from the railway point of view?


a year ago

yes


a year ago

your docker compose file states you are using postgres 12, does it need to be an older version? would postgres 16 work?


a year ago

sorry for the late reply, I was asleep


Anonymous
TRIAL

a year 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.


Anonymous
TRIAL

a year ago

no worry at all, sleepping is good hobby haha


a year 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


Anonymous
TRIAL

a year ago

ok thanks, how can we start?


a year ago

deploy postgres into your project from the create button on your project canvas


Anonymous
TRIAL

a year ago

deployed


a year 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


Anonymous
TRIAL

a year ago

1254834335320903700


a year ago

did you delete the fastapi service? where did it go?


Anonymous
TRIAL

a year ago

I created a new, should I delete the previous project?


a year ago

yeah delete the old project, we want everything inside of one project


Anonymous
TRIAL

a year ago

deleted

1254835222143439000


a year ago

open that project and change the project name to something more suitable


Anonymous
TRIAL

a year ago

done


a year ago

please remeber the screenshots


Anonymous
TRIAL

a year ago

1254835699836911600


a year ago

okay create a new empty service, name it properly as the backend, and configure any service variables it will need


Anonymous
TRIAL

a year 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


Anonymous
TRIAL

a year ago

is that more straightforward


a year ago

pull from where?


Anonymous
TRIAL

a year ago

docker hub


a year ago

is it a public image?


Anonymous
TRIAL

a year ago

I can set it to public


a year ago

then yes, you can have the service pull the public image, but you still need to set service variables


a year ago

so please go ahead and do this


Anonymous
TRIAL

a year 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.


a year 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


Anonymous
TRIAL

a year 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?


a year ago

basically yes, but treafik is not going to work on railway, there is no way to do labels


Anonymous
TRIAL

a year ago

ok, so there will be some railway specific reverse proxy service setup.


a year ago

not really, you will have to redo the proxy with something better, like caddy


Anonymous
TRIAL

a year ago

ok. sounds like you bring me out of comfort zone


a year ago

but maybe you wont even need any reverse proxy, can you tell me why you had one to begin with?


Anonymous
TRIAL

a year ago

I mean as a edge router, accepting the main request load, load balancer, ssl termination, internal service routing, middleware setup somthing like that.


Anonymous
TRIAL

a year ago

no special


a year 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?


Anonymous
TRIAL

a year ago

yes


Anonymous
TRIAL

a year ago

is railway designed for frontend deployment or should I only put backend here and deploy frontend somewhere else


a year ago

you have designed your own deployment, you use nginx to serve the frontend, so you are good to go


a year ago

are you aware that railway handles ssl for you?


Anonymous
TRIAL

a year ago

so solely nginx is enough for serving the frontend, no need traefic any more?


a year ago

correct


a year ago

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


Anonymous
TRIAL

a year ago

ok, sounds like straightforward.


a year ago

feel free to ping when you have more time to jump back into this


Anonymous
TRIAL

a year ago

I feel railway is designed primarily for backend, is that true. should I put frontend to some where else?


a year 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


Anonymous
TRIAL

a year ago

ok, got it. thx. good night / good day. appreciate your kindly help


a year ago

you too!


deploy react+fastapi+postgresql+celery on railway - Railway Help Station