deploy react+fastapi+postgresql+celery on railway

AnonymousTRIAL

10 months 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

10 months 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.


10 months ago

n/a


AnonymousTRIAL

10 months ago


AnonymousTRIAL

10 months ago

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


AnonymousTRIAL

10 months 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.


10 months ago

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


10 months ago

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


10 months ago

can you show me a screenshot of your railway project?


AnonymousTRIAL

10 months 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.


AnonymousTRIAL

10 months ago

1254674828791906300


AnonymousTRIAL

10 months ago

this is the screenshot running local dockers.


AnonymousTRIAL

10 months 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


AnonymousTRIAL

10 months 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.


AnonymousTRIAL

10 months ago

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


10 months ago

yes


10 months ago

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


10 months ago

sorry for the late reply, I was asleep


AnonymousTRIAL

10 months 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.


AnonymousTRIAL

10 months ago

no worry at all, sleepping is good hobby haha


10 months 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


AnonymousTRIAL

10 months ago

ok thanks, how can we start?


10 months ago

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


AnonymousTRIAL

10 months ago

deployed


10 months 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


AnonymousTRIAL

10 months ago

1254834335320903700


10 months ago

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


AnonymousTRIAL

10 months ago

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


10 months ago

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


AnonymousTRIAL

10 months ago

deleted

1254835222143439000


10 months ago

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


AnonymousTRIAL

10 months ago

done


10 months ago

please remeber the screenshots


AnonymousTRIAL

10 months ago

1254835699836911600


10 months ago

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


AnonymousTRIAL

10 months 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


AnonymousTRIAL

10 months ago

is that more straightforward


10 months ago

pull from where?


AnonymousTRIAL

10 months ago

docker hub


10 months ago

is it a public image?


AnonymousTRIAL

10 months ago

I can set it to public


10 months ago

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


10 months ago

so please go ahead and do this


AnonymousTRIAL

10 months 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.


10 months 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


AnonymousTRIAL

10 months 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?


10 months ago

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


AnonymousTRIAL

10 months ago

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


10 months ago

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


AnonymousTRIAL

10 months ago

ok. sounds like you bring me out of comfort zone


10 months ago

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


AnonymousTRIAL

10 months ago

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


AnonymousTRIAL

10 months ago

no special


10 months 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?


AnonymousTRIAL

10 months ago

yes


AnonymousTRIAL

10 months ago

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


10 months ago

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


10 months ago

are you aware that railway handles ssl for you?


AnonymousTRIAL

10 months ago

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


10 months ago

correct


10 months 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


AnonymousTRIAL

10 months ago

ok, sounds like straightforward.


10 months ago

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


AnonymousTRIAL

10 months ago

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


10 months 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


AnonymousTRIAL

10 months ago

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


10 months ago

you too!