R
Railway•4mo ago
OPJerry

Error: Docker build failed

I'm trying to run my first ever web app on this website but i have failed Python-Django
No description
210 Replies
Percy
Percy•4mo ago
Project ID: N/A
OPJerry
OPJerry•4mo ago
what should i do now ?
Brody
Brody•4mo ago
try adding a nixpacks.toml file to your project with this in it
[phases.setup]
nixPkgs = ['...', 'postgresql']
[phases.setup]
nixPkgs = ['...', 'postgresql']
OPJerry
OPJerry•4mo ago
let me check where should i apply this ? just this file, with this text ?
Brody
Brody•4mo ago
correct
OPJerry
OPJerry•4mo ago
OPJerry
OPJerry•4mo ago
GitHub
GitHub - OPJerry/Django-BrainStorm: One of my projects. This is web...
One of my projects. This is web app named "BrainStorm". App was created to help small or midsize companies, develop and manage the ideas of upcoming projects. - GitHub - OPJerry/D...
Brody
Brody•4mo ago
I'm not seeing the nixpacks.toml file?
OPJerry
OPJerry•4mo ago
ok, my mistake i added "phases.setup"
OPJerry
OPJerry•4mo ago
Brody
Brody•4mo ago
the file name is still incorrect and the contents of the file is incorrect please have another look at this message
Brody
Brody•4mo ago
yep, not gonna work if the file contents are incorrect
OPJerry
OPJerry•4mo ago
nixPkgs = ['...', 'postgresql'] is wrong ?
Brody
Brody•4mo ago
yes it is, please have another very careful look at this message
OPJerry
OPJerry•4mo ago
should i type " [phases.setup] " before ?
Brody
Brody•4mo ago
of course, it's part of the code block
Brody
Brody•4mo ago
you are trying to install a windows specific python module pywin32 but railway runs your code in a Linux environment, you would need to remove that module from your requirements.txt file. though it looks like you froze every module you had installed on your computer into the requirements.txt file so you will need to go through the file and remove anything your project doesn't use
OPJerry
OPJerry•4mo ago
ok let me try to quickly prepare this module for railway. do you see any else module that are bordering ? i can truly see that i made a mistake at the beginning by build this app without virtual environment...
Brody
Brody•4mo ago
I'd have to look through every file in your app to tell, that is a better task for the creator of this project
OPJerry
OPJerry•4mo ago
Is this same error ? if yes i will just fix it later and come back again tomorrow
Brody
Brody•4mo ago
not the exact same error but similar, it's trying to install another windows only module
OPJerry
OPJerry•4mo ago
let me use chatGPT, wait a minute
Brody
Brody•4mo ago
might make things worse, this is better left as a manual process from the logs, you know you need to at least remove pywinpty
OPJerry
OPJerry•4mo ago
where did you see the message that the pywin is making the error ? im trying to fix all the error by myself not wasting your time
Brody
Brody•4mo ago
I saw it in the logs you have just provided me
OPJerry
OPJerry•4mo ago
No matching distribution found for guniconn==21.2.0 ? ok it should be gunicorn i guess
Brody
Brody•4mo ago
yep thats a typo
OPJerry
OPJerry•4mo ago
I'm starting to get it
OPJerry
OPJerry•4mo ago
ok, i fixed 2 more error, the app runs correctly, but after 10s it crashed.
Brody
Brody•4mo ago
ModuleNotFoundError: No module named 'corsheaders'
ModuleNotFoundError: No module named 'corsheaders'
OPJerry
OPJerry•4mo ago
should i update requirements.txt by typing corsheaders ?
Brody
Brody•4mo ago
yes, it looks like your code needs it
OPJerry
OPJerry•4mo ago
Can I buy you a coffee for that asking stupid questions?
Brody
Brody•4mo ago
lmao im not gonna say no, but you really dont have to
OPJerry
OPJerry•4mo ago
I'm sorry man, how can i give you a tip?
Brody
Brody•4mo ago
you're welcome to buy me a coffee, but you dont need to, im happy to help either way
OPJerry
OPJerry•4mo ago
It's no big deal, I won't feel it, don't worry. Just give me your a website for tips or bank account
Brody
Brody•4mo ago
its in my bio if you insist
OPJerry
OPJerry•4mo ago
app is working but looking like a piece of sh*** all the templates are fall down for no reason 😄
Brody
Brody•4mo ago
no css?
OPJerry
OPJerry•4mo ago
looks like no css, or done wrong way. but on my computer everything looks nice
Brody
Brody•4mo ago
do you use whitenoise? are you collecting the static files?
OPJerry
OPJerry•4mo ago
i did not collect static files. because when i type the command, they ask me "are you sure i wont to do that? that will replace your folder" and i was afraid that i will have to assign that again in every single template
OPJerry
OPJerry•4mo ago
that's how it should look like
No description
Brody
Brody•4mo ago
theres a flag to auto accept that, try setting your Procfile to this
web: python manage.py collectstatic --noinput && gunicorn DjangoApp.wsgi --log-file -
web: python manage.py collectstatic --noinput && gunicorn DjangoApp.wsgi --log-file -
OPJerry
OPJerry•4mo ago
that how it looks
No description
Brody
Brody•4mo ago
for sure case of no css try the Procfile i sent
OPJerry
OPJerry•4mo ago
still same
OPJerry
OPJerry•4mo ago
i guess it's not reading my static files
Brody
Brody•4mo ago
incorrect format, use just the line i gave you
No description
OPJerry
OPJerry•4mo ago
should i remove 1 line ? ok
Brody
Brody•4mo ago
correct
Brody
Brody•4mo ago
OPJerry
OPJerry•4mo ago
is this a module that i have to have in requirements
Brody
Brody•4mo ago
yeah you would need to add a module to the requirements.txt file for white noise, read through the two docs pages i linked
OPJerry
OPJerry•4mo ago
OK look like we are getting close to the end 🙂 but now i have CSRF verification failed. Request aborted. when im trying to login/register do you have any idea what cause this
Brody
Brody•4mo ago
im not a django dev so i dont have any first hand experance with that, but i know that django has some good docs on that! and since you are running in debug mode, the error would have given you the resources you need to fix said error
OPJerry
OPJerry•4mo ago
ok 😄 but it looks like we have all right at the raiway.app
Brody
Brody•4mo ago
progress!
OPJerry
OPJerry•4mo ago
thank you for not giving me fish but teaching me how to fish
Brody
Brody•4mo ago
i dont have any fish, im not even a python dev
OPJerry
OPJerry•4mo ago
i will try to do some bug fixing in the code, and maybe tomorrow set up another app
Brody
Brody•4mo ago
so css is fixed but csrf is not?
OPJerry
OPJerry•4mo ago
That how we say in Polnad. " thank you for teaching me how to handle issues by myself " yeah, it works well on my local server in my PC. But something is getting wrong when im using it online
Brody
Brody•4mo ago
yes to css?
OPJerry
OPJerry•4mo ago
CSRF mean Cross-Site Request Forgery CSRF is a security feature in Django to protect against malicious form submissions from other sites.
Brody
Brody•4mo ago
yeah i do know what it stands for, im just asking if the no css issue has been fixed
OPJerry
OPJerry•4mo ago
yes. done. LOOKS LIKE IT SHOULD the server responds very quickly
Brody
Brody•4mo ago
okay so csrf issue remains?
OPJerry
OPJerry•4mo ago
yup
Brody
Brody•4mo ago
have you looked at the guide that the csrf error page gives you?
OPJerry
OPJerry•4mo ago
i'm looking at it right now, give me a minute brother docs done, i made some adjustments but nothing helped oh :thonk: it should work. is there a chance that issue is on the railwapp site ?
Brody
Brody•4mo ago
no chance very common config issue with django that a lot of people run into when hosting for production, not just on railway
OPJerry
OPJerry•4mo ago
where did you get your knowledge ? you're a very smart man know a lot about everyting 😄 for real I wouldn't even set up a server without you
Brody
Brody•4mo ago
just by running around helping people
OPJerry
OPJerry•4mo ago
that the message i have. IF YOU HAVE TIME FOR LOOKING A IT OF COURSE Forbidden (403) CSRF verification failed. Request aborted. Help Reason given for failure: Origin checking failed - https://web-production-bf8e.up.railway.app does not match any trusted origins.
In general, this can occur when there is a genuine Cross Site Request Forgery, or when Django’s CSRF mechanism has not been used correctly. For POST forms, you need to ensure: Your browser is accepting cookies. The view function passes a request to the template’s render method. In the template, there is a {% csrf_token %} template tag inside each POST form that targets an internal URL. If you are not using CsrfViewMiddleware, then you must use csrf_protect on any views that use the csrf_token template tag, as well as those that accept the POST data. The form has a valid CSRF token. After logging in in another browser tab or hitting the back button after a login, you may need to reload the page with the form, because the token is rotated after a login. You’re seeing the help section of this page because you have DEBUG = True in your Django settings file. Change that to False, and only the initial error message will be displayed. You can customize this page using the CSRF_FAILURE_VIEW setting.
Brody
Brody•4mo ago
have you added that domain to the trusted origins?
OPJerry
OPJerry•4mo ago
\
No description
OPJerry
OPJerry•4mo ago
yes, by using *
Brody
Brody•4mo ago
have you added the {% csrf_token %} thingy?
OPJerry
OPJerry•4mo ago
yes
Brody
Brody•4mo ago
done everything else that page says?
OPJerry
OPJerry•4mo ago
i checked twice and i realise i didn't. lets see if this helps
Brody
Brody•4mo ago
its just one thing you are forgetting somewhere
OPJerry
OPJerry•4mo ago
That's the taste of programing. small things Makes BIG difference
Brody
Brody•4mo ago
very true
OPJerry
OPJerry•4mo ago
that was it. now it works i think every single things works.... after 3,5h hahahahaha
Brody
Brody•4mo ago
so how much more time you got, because theres one major issue that i have yet to mention
OPJerry
OPJerry•4mo ago
all night
Brody
Brody•4mo ago
okay then lets dig in you are using sqlite, therefor every time you push code the sqlite database in your repo replaces the sqlite database on railway since the container does not have persistent storage
OPJerry
OPJerry•4mo ago
yeah i fuc*** up with this
Brody
Brody•4mo ago
so you need to use postgres going forward
OPJerry
OPJerry•4mo ago
i think i know how to change it i've done one project with postgres and the database is on your app
Brody
Brody•4mo ago
theres about a dozen ways you could do the move to postgres wrong though so do you want me to walk you through it at a high level?
OPJerry
OPJerry•4mo ago
is there a chance to move my data to postgres without losing it ? there is NOTHING important there but it would be great to know that Teach me master.
Brody
Brody•4mo ago
i have never moved the data from an sqlite database to postgres, so im in no position to guide you on that, but i can get you setup with an empty postgres database
OPJerry
OPJerry•4mo ago
right clik on our railway.app and then start postgresSQL ?
Brody
Brody•4mo ago
right click on the canvas -> database -> postgres
OPJerry
OPJerry•4mo ago
ok postgres alive
Brody
Brody•4mo ago
screenshot please
OPJerry
OPJerry•4mo ago
No description
Brody
Brody•4mo ago
paste these into the raw editor of the web service
PGDATABASE=${{Postgres.PGDATABASE}}
PGHOST=${{Postgres.PGHOST}}
PGPASSWORD=${{Postgres.PGPASSWORD}}
PGPORT=${{Postgres.PGPORT}}
PGUSER=${{Postgres.PGUSER}}
PGDATABASE=${{Postgres.PGDATABASE}}
PGHOST=${{Postgres.PGHOST}}
PGPASSWORD=${{Postgres.PGPASSWORD}}
PGPORT=${{Postgres.PGPORT}}
PGUSER=${{Postgres.PGUSER}}
then save the changes with alt + shift + enter
OPJerry
OPJerry•4mo ago
should i change the password immediately etc. whether it will be assigned automatically
Brody
Brody•4mo ago
literally paste the code block into the raw editor, do not change a single thing
OPJerry
OPJerry•4mo ago
ENV or JSON
Brody
Brody•4mo ago
env
OPJerry
OPJerry•4mo ago
done
Brody
Brody•4mo ago
have you saved?
OPJerry
OPJerry•4mo ago
yes deply button ? deploy*
Brody
Brody•4mo ago
save the changes with alt + shift + enter
OPJerry
OPJerry•4mo ago
whoooah assigned automatically
Brody
Brody•4mo ago
yeah we dont need to deploy since we are about to make code changes and that will count as the deploy
OPJerry
OPJerry•4mo ago
what a fantastic website
Brody
Brody•4mo ago
its pretty nifty
OPJerry
OPJerry•4mo ago
now let's check our data 😄 ok still there. very good
Brody
Brody•4mo ago
we arent there yet, but i like your enthusiasm
OPJerry
OPJerry•4mo ago
😄
OPJerry
OPJerry•4mo ago
ops. File "C:\Users\Jerry\Desktop\BrainStorm\DjangoApp\settings.py", line 101, in <module> 'NAME': os.environ["PGDATABASE"], ^^ NameError: name 'os' is not defined
Brody
Brody•4mo ago
oh yeah, you need to import os i figured your ide would warn you about that though :mildpanic:
OPJerry
OPJerry•4mo ago
should i ignore it ? ok
Brody
Brody•4mo ago
no, you need to import os
OPJerry
OPJerry•4mo ago
just typed teah yeah dumb question don't get me wrong :DO i'm not that stupid, just tired commit done. shuld i remove previos app from web.deployments ?
Brody
Brody•4mo ago
what do you mean?
OPJerry
OPJerry•4mo ago
No description
OPJerry
OPJerry•4mo ago
deleting this
Brody
Brody•4mo ago
that will disapear automatically when the new deployment goes through
OPJerry
OPJerry•4mo ago
it happened as you said :HAHAHA: app not working hahaha
Brody
Brody•4mo ago
figured, you need to run migrations
OPJerry
OPJerry•4mo ago
ok i know how to do it where we have app terminal now ?
Brody
Brody•4mo ago
your new Procfile should be
web: python manage.py migrate && python manage.py collectstatic --noinput && gunicorn DjangoApp.wsgi --log-file -
web: python manage.py migrate && python manage.py collectstatic --noinput && gunicorn DjangoApp.wsgi --log-file -
nope, railway doesnt provide ssh access to the container
OPJerry
OPJerry•4mo ago
ok so just replace the line in Procfile do this and next commit
Brody
Brody•4mo ago
yeah i think this is all thats needed, you will just have to find a way to move your data over from sqlite
OPJerry
OPJerry•4mo ago
maybe tommorow i will finde a way to make a "PUT" method in the database
Brody
Brody•4mo ago
task for another day
OPJerry
OPJerry•4mo ago
nope, still not woring
Brody
Brody•4mo ago
theres no data in the database i cant see how it could work
OPJerry
OPJerry•4mo ago
that mean migration didnt work
Brody
Brody•4mo ago
oh, send the deploy logs
Brody
Brody•4mo ago
send the build logs too
Brody
Brody•4mo ago
you have the start command being overwritten somewhere, check your service settings
OPJerry
OPJerry•4mo ago
in django you make migrations by typing in terminal python manage.py make migrations and then you type python manage.py migrate maybe this manage.py app is doing some mess i've done one local webapp with railway postgreSQL and that how it worked there
Brody
Brody•4mo ago
doing it in the start command is fine too have you checked?
OPJerry
OPJerry•4mo ago
yeah, but i don't see anything that should border us creating apss in Django is based on just adding functionalities to exsisting framework
Brody
Brody•4mo ago
do you have a start command set in the service settings?
OPJerry
OPJerry•4mo ago
what do you exacly mean the command im runing server ? if i want to start it up locally ?
Brody
Brody•4mo ago
please look into the railway service settings, do you have a start command set there? (yes/no)
OPJerry
OPJerry•4mo ago
i'm looking from one place to another in our project settings but i don't see any start command set
OPJerry
OPJerry•4mo ago
we talk about this page yes ?
No description
Brody
Brody•4mo ago
nope, look in the service settings first open the service, then click settings
OPJerry
OPJerry•4mo ago
No description
OPJerry
OPJerry•4mo ago
this one ?
Brody
Brody•4mo ago
you opened your account settings
OPJerry
OPJerry•4mo ago
ok our webapp setings
Brody
Brody•4mo ago
go back to the project, open the service, and then click settings
OPJerry
OPJerry•4mo ago
No description
OPJerry
OPJerry•4mo ago
No description
Brody
Brody•4mo ago
remove it
OPJerry
OPJerry•4mo ago
No description
OPJerry
OPJerry•4mo ago
confirmed
Brody
Brody•4mo ago
click deploy if you haven't already
OPJerry
OPJerry•4mo ago
done
Brody
Brody•4mo ago
did stuff fail?
OPJerry
OPJerry•4mo ago
"deploying" ok done railway error : Application failed to respond
Brody
Brody•4mo ago
deploy logs please
Brody
Brody•4mo ago
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
OPJerry
OPJerry•4mo ago
hmm, what went wrong if everything was good i settings app DIR is corect ok ok
Brody
Brody•4mo ago
please give that error message a read this is likely what you want to set it to https://github.com/railwayapp-templates/django/blob/main/mysite/settings.py#L129
OPJerry
OPJerry•4mo ago
what do you think. typing : STATIC_ROOT = 'static/' will work ? ok
Brody
Brody•4mo ago
didnt the whitenose docs tell you what to set?
OPJerry
OPJerry•4mo ago
building webapp again i guess you have around 5 kids because you are patience like monk man 😄 app is working
Brody
Brody•4mo ago
app works but without any data, I think the rest is up to you now eh?
OPJerry
OPJerry•4mo ago
https://web-production-bf8e.up.railway.app do you se my post in the middle of the app with blue avatar ? yeah
Brody
Brody•4mo ago
yeah i see the post
OPJerry
OPJerry•4mo ago
Is something i can do for you anything ?
Brody
Brody•4mo ago
i dont need anything in return
OPJerry
OPJerry•4mo ago
i hope you gonna become at least team leader in this company
Brody
Brody•4mo ago
I don't even work for them lol
OPJerry
OPJerry•4mo ago
how this is possible
Brody
Brody•4mo ago
not qualified haha
OPJerry
OPJerry•4mo ago
im jumping off a cliff :HAHAHA:
Brody
Brody•4mo ago
alright let's not say that even as a joke please
OPJerry
OPJerry•4mo ago
ok so if anyone can see this. Me Jeremy from Poland would like to highly recommend this person (Brody) to become full time worker for railway if he would like to
Brody
Brody•4mo ago
haha I appreciate that
OPJerry
OPJerry•4mo ago
can i somehow save this conversation ?
Brody
Brody•4mo ago
it's not going anywhere
OPJerry
OPJerry•4mo ago
i thing i will need it sooner or later fuck
Brody
Brody•4mo ago
just copy the link, no one is going to delete it
OPJerry
OPJerry•4mo ago
it's been a loong day do you work as a programist ? in any other company ?
Brody
Brody•4mo ago
nope
OPJerry
OPJerry•4mo ago
me to but im trying to finde something, that why im learing how to start my app's online but man, this scares the fuck out of me that YOU dont work for any company
Brody
Brody•4mo ago
you've done more than me in that regard, I've never created anything as complex as the app you just showed me
OPJerry
OPJerry•4mo ago
i can teach you anything i know if you have time later or we can build our own company i will type apps you will set it up on the internet
Brody
Brody•4mo ago
only problem, i dont much like python 🤣
OPJerry
OPJerry•4mo ago
no problem. don't look at the code, just keep your eyes on the money 😂 do you have github ? anyway, feel free to ask me about anything in the future time to sleep form me.
Brody
Brody•4mo ago
same to you, any railway questions, open a help thread
OPJerry
OPJerry•4mo ago
i started the day at 5am 10h work then coding and now its 3am that how my live looks like :HAHAHA:
Brody
Brody•4mo ago
very nice thanks for the train! hey can i dm you for a django related favor? @OPJerry tag for viz
OPJerry
OPJerry•4mo ago
Yes @Brody add me to firendlist
Brody
Brody•4mo ago
haha my bad, forgot about that setting