Deploying for the first time
Hi, I am new to railroad and I am trying to deploy my flask app.
I am getting this error:
In the attached screenshot you can see how I am setting the build command.
Do I need to add a Dockerfile to my project? I never done that before so I am confused on what to do to fix this.
Thank you in advance for reading!
72 Replies
Project ID:
N/A
N/A
I don't know where to find my project Id
Hello, how did you come up with this build command?
There's a few flask templates you could reference.
https://railway.app/template/zUcpux
Hey @intro , I'm not completely sure about a solution to you're problem, but here's a good start: you're build script has a bunch of things && together, try doing just one of them at a time and see which ones trigger the error. And yes, using a docker file would probably be a straight forward way to get this to work.
@Finesse it says
line 1: npm: command not found
so i assume it somehow does not know npm?
It's from a starter project I used before. It comes with user authentication@intro have you tried not doing a custom build command?
Using the Railway template. (When you first choose a project to deploy, choosing the "deploy flask app" option.
Relevant:
https://railway.app/new/template/zUcpux
to provide you with help we would need to see your repo to understand what's going on with your app
this is the current state of my app:
https://github.com/hannarosenfeld/vault-manager
GitHub
GitHub - hannarosenfeld/vault-manager
Contribute to hannarosenfeld/vault-manager development by creating an account on GitHub.
i used their flask template and modified it a bit. it's still quite simple - see my repo above
you modified it a lot
the template repo didnt have a dockerfile
i added the dockerfile because i obv don't know what i am doing
i just want to deploy my site lol
i need a front and a backend
the backend needs to be flask and the frontend needs to be react
haha no worries, we'll get you sorted
so while we work through this, go ahead and remove the repo from your service so we arent triggering a new build for every little change
remove my github repo from the railway project?
from the railway service
there would be a little x button besides the repo listing in the service settings
this?
yep, you can remove both those
ok just did
okay so you will now want to re-structure your repo into a monorepo
rename
react-app
to frontend
and then put everything expect readme.md and the frontend
folder into a backend
foldershould i remove the dockerfile?
ah yes you should, good catch
ok just did
should i push my changes?
yes please
ok done
oh should i have renamed "app" to "backend" ?
if you want to, it is a backend after all
ok done and pushed to main
okay lets get working on the backend first
show me a screenshot of the entire railway project
this?
yep, going forward you will use that service for just your backend, so give it a name that signifies its the service for the backend
later we will create another service for the frontend, but we will cross that bridge when we get to it
ok, and i keep the postgres db?
yes!
give it a name that signifies its the service for the backendoh i see what you did, you want to change the service name, not the project name remove the backend suffix from the project name
perfect
rename
__init__.py
to main.py
and remove the static_folder='../react-app/build', static_url_path='/'
stuff from itok done and pushed to main
now just do a quick check locally and make sure you can run your backend still
i can
now you will need a
railway.json
file in your backend, so railway knows how to run the backend service
Actually, I am getting an error:
I think it is refering to the .flaskenv
where are you trying to import backend, and why?
i'm not sure.. i am sure though it's from the .flaskenv variable FLASK_APP. Changing it's value changes the value in the error:
remove the file lol
then i can't run the backend anymore
just add
to the bottom of your main.py file, then you can start the flask server with
python main.py
should that be
from models import db, user
without the period?no it's User and worked before
the file name has a lower case
u
it is refering to the actual user model
changing it to lowercase gives the same error
and yes i know it worked before, but you had an improper directory structure before
yeah it was pretty messy
so please get your codebase working locally before we proceed
since i can't seem to figure this out i will create a minimal flask app and work from there
sounds good
nevermind i am encounterin the same issue here as well when moving my files to the backend as we did earlier
alright no worries, ill be around, just let me know when you are ready to proceed
ok i got a simple app running now. let's take it from here:
https://github.com/hannarosenfeld/vault-manager
GitHub
GitHub - hannarosenfeld/vault-manager
Contribute to hannarosenfeld/vault-manager development by creating an account on GitHub.
i dont think these linked folders will work on railway
i also cant see whats inside of them
apologies, let's try this:
https://github.com/hannarosenfeld/vault-manager
GitHub
GitHub - hannarosenfeld/vault-manager
Contribute to hannarosenfeld/vault-manager development by creating an account on GitHub.
that looks like it shall work
I added the railway file just now
in your backend railway service, set the root directory to
/backend
then add this repo to the service
ah you had a procfile, so i didnt mention the railway.json file
but now that you have the railway.json leave it, and delete the old style heroku Procfiledone
push the changed then do this
i'm getting the same error i got since the beginning now:
sorry i realized i still had that old build command in settings. just removed.
building again.
haha beat me to it
the build completed though i can't see my site when i click on the link. deploy logs giving me a bunch of errors. what stands out to me is this:
ModuleNotFoundError: No module named 'main.app'; 'main' is not a package
related to the railway file?
oh my bad, it would be
main:app
yay it's live now
thank you
i will create my models etc from here and probably be back with more errors at some point ^^
sounds good, let me know when you want to tackle the seprate frontend service
it should be plenty easy to get your original react app running on railway instead of this same react app
for context, frontend solved in a new thread