Trouble deploying Flask app on separate folder
Hey, so I am new to Railway and I built an app with a Flask backend and a frontend in Svelte and I am facing some issues on deployment from my repo. Here is my repo: https://github.com/ssantoshp/inhouse/tree/main
I am pretty sure there is a way to solve my problem easily but I just tried a bunch of things and none of them really worked well.
So, from my understanding the building should only happen from my
api
folder but when I set "Root directory" to /api
" it seems like I cannot find my html templates from the client
folder.
I think there is something that is missing in what I am doing. I tried setting the "Root directory" to /
and then doing cd api && gunicorn --timeout 300 "main:app" --threads 4
but then the app is unable to build because it doesnt how to build this (the /
directory).
Thanks!85 Replies
Project ID:
ab00c838-3b0f-46a2-af19-7ddc8661e5c6
ab00c838-3b0f-46a2-af19-7ddc8661e5c6
this is a mono repo with two apps, a backend and a frontend, this means you need two railway services, and you would set the root directory to use either /frontend or /backend respectively
and for these two types of apps, you should not be specifying any build or start commands in their service settings
ok but am I able to keep the same domain name for both?
or do I make one for the api and one for the frontend?
no, you would have domain.com for the frontend and api.domain.com for the backend
i can understand the desire for the same domain, but its a bit of a hassle and not worth it in my opinion
ok, thats my first doing time doing this but just out of curiosity is it common practice do deploy 2 apps or is just due to railway?
yup that makes sense
yep two apps, two services
perfect thanks for the quick reply!
i will say, your backend is missing a Procfile
oh yeah right, I used to have one ill push it too
thanks!
hey are you having some troubles getting your frontent online?
hey! yes I am
It keeps doing
And it eventually times out
I've seen that doing
npm install --omit=dev
in my package.json usually solve the npm WARN
but it still failsyou can ignore that warning, and remove the install script
hmm how can I do that?
just delete line 12 in your package.json
oh yeah but thats what I did originally
I didnt have any install script
and then I tried adding
npm install --omit=dev
have you set any build or start commands in your service settings
no
good
just Root directory to /client
build and start are left empty
perfcet
retried and it deployed, I guess i need to change start to make it display the page?
run
npm i serve
and then change your start script to serve public -s -n -L -p $PORT
I get this for now
https://inhouse.up.railway.app/
^
okey
do I add npm i serve to my package.json?
the command adds it on its own
im confused with
npm i serve
oh ok
got t
got it
downloading
ok updated lets see
https://inhouse.up.railway.app/
i just restarted
it crashedyou did not do what i said to
^
I did, what did I miss?
i added this to start and put package.json after npm i serve
the second half of those in instructions
its not it?
instructions?
instructions
that is not the start script
oh okk
sorry mb
remove it
ok done, sorry for the misunderstanding
loading now
no worries
hmm
https://github.com/ssantoshp/inhouse/blob/main/client/package.json
here is the package.json
but still crashes
show me the logs please
yup
thats not a crash 🙄
it failed I meant
your lock file is somehow 2 weeks out of sync
oh
this I shall update too
run
npm i --package-lock-only
ok updated
oh
for your own sanity please start using vite
i heard of it
but yeah i will promise
i beg you, please use it
how does it help me in this situation?
your public folder is a mess
oh
...
what part
the part where its not a single page app
but you are trying to treat it like one
wdym? how do I treat it like one?
is svelte just for single page?
just take my advice and start using vite asap
okey we'll do
npm WARN config production Use
--omit=dev
instead.
[email protected] start serve public -s -n -L -p $PORTINFO Accepting connections at http://localhost:5473 for the deploy log https://inhouse.up.railway.app/
looks good
that works
i think
now move to vite to fix the rest of the issues with your app
opens not the good page tho
vite
😢
have fun
lol i need to figure out why and how now lol but thanks for all the help!
vite has a svelte plugin, it will be super easy
just go find a vite/sveltle template to reference it
but does it mean I can keep my multiple html files?
or should I manage to make them a spa
vite is only for single page apps
oh boi
Vite
Next Generation Frontend Tooling
is there hope
so id need a rewrite?
just convert to a spa and do client side routing
ill have to look into that then ig
yes you will
i should at some point
thanks!
prob should have before you started this project tbh
it is what it is, we learn along the way 😉
thats a good lesson for later projects
i like the positivity!
i wish you good luck
Thank you so much for your help!
no problem!
@Brody Can I DM you?
#🛂|readme #5 - no pings
youre funny