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
hi thx for the reply. the repo is here https://github.com/tianerphil/full-stack-fastapi-template.git
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.
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?
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.
and this one is the one I tried to deploy to railway. I have installed railway cli, and used railway init, and railway up
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.
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
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.
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
10 months ago
deploy postgres into your project from the create button on your project canvas
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
10 months ago
did you delete the fastapi service? where did it go?
10 months ago
yeah delete the old project, we want everything inside of one project
10 months ago
open that project and change the project name to something more suitable
10 months ago
please remeber the screenshots
10 months ago
okay create a new empty service, name it properly as the backend, and configure any service variables it will need
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
10 months ago
pull from where?
10 months ago
is it a public image?
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
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
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
10 months ago
not really, you will have to redo the proxy with something better, like caddy
10 months ago
but maybe you wont even need any reverse proxy, can you tell me why you had one to begin with?
I mean as a edge router, accepting the main request load, load balancer, ssl termination, internal service routing, middleware setup somthing like that.
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?
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?
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
10 months ago
feel free to ping when you have more time to jump back into this
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
10 months ago
you too!