Error: Docker build failed
I'm trying to run my first ever web app on this website
but i have failed
Python-Django
210 Replies
Project ID:
N/A
build logs please https://bookmarklets.up.railway.app/log-downloader/
what should i do now ?
try adding a nixpacks.toml file to your project with this in it
let me check
where should i apply this ?
just this file, with this text ?
correct
still failed
app in django on github: https://github.com/OPJerry/Django-BrainStorm
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...
I'm not seeing the nixpacks.toml file?
ok, my mistake i added "phases.setup"
Failed
the file name is still incorrect
and the contents of the file is incorrect
please have another look at this message
yep, not gonna work if the file contents are incorrect
nixPkgs = ['...', 'postgresql'] is wrong ?
yes it is, please have another very careful look at this message
should i type " [phases.setup] " before ?
of course, it's part of the code block
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 useok 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...
I'd have to look through every file in your app to tell, that is a better task for the creator of this project
Is this same error ? if yes i will just fix it later and come back again tomorrow
not the exact same error but similar, it's trying to install another windows only module
let me use chatGPT, wait a minute
might make things worse, this is better left as a manual process
from the logs, you know you need to at least remove
pywinpty
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
I saw it in the logs you have just provided me
No matching distribution found for guniconn==21.2.0 ?
ok it should be gunicorn i guess
yep thats a typo
I'm starting to get it
ok, i fixed 2 more error, the app runs correctly, but after 10s it crashed.
should i update requirements.txt by typing corsheaders ?
yes, it looks like your code needs it
Can I buy you a coffee for that asking stupid questions?
lmao im not gonna say no, but you really dont have to
I'm sorry man, how can i give you a tip?
you're welcome to buy me a coffee, but you dont need to, im happy to help either way
It's no big deal, I won't feel it, don't worry. Just give me your a website for tips or bank account
its in my bio if you insist
app is working but looking like a piece of sh*** all the templates are fall down for no reason 😄
no css?
looks like no css, or done wrong way. but on my computer everything looks nice
do you use whitenoise?
are you collecting the static files?
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
that's how it should look like
theres a flag to auto accept that, try setting your Procfile to this
that how it looks
for sure case of no css
try the Procfile i sent
still same
i guess it's not reading my static files
incorrect format, use just the line i gave you
should i remove 1 line ?
ok
correct
yep, you dont have the
WhiteNoiseMiddleware
heres docs for that
https://whitenoise.readthedocs.io/en/latest/index.html
https://whitenoise.readthedocs.io/en/latest/django.htmlis this a module that i have to have in requirements
yeah you would need to add a module to the requirements.txt file for white noise, read through the two docs pages i linked
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
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
ok 😄
but it looks like we have all right at the raiway.app
progress!
thank you for not giving me fish but teaching me how to fish
i dont have any fish, im not even a python dev
i will try to do some bug fixing in the code, and maybe tomorrow set up another app
so css is fixed but csrf is not?
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
yes to css?
CSRF mean Cross-Site Request Forgery
CSRF is a security feature in Django to protect against malicious form submissions from other sites.
yeah i do know what it stands for, im just asking if the no css issue has been fixed
yes. done.
LOOKS LIKE IT SHOULD
the server responds very quickly
okay so csrf issue remains?
yup
have you looked at the guide that the csrf error page gives you?
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 ?
no chance
very common config issue with django that a lot of people run into when hosting for production, not just on railway
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
just by running around helping people
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.
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.
have you added that domain to the trusted origins?
\
yes, by using *
have you added the
{% csrf_token %}
thingy?yes
done everything else that page says?
i checked twice and i realise i didn't.
lets see if this helps
its just one thing you are forgetting somewhere
That's the taste of programing. small things Makes BIG difference
very true
that was it.
now it works
i think every single things works....
after 3,5h
hahahahaha
so how much more time you got, because theres one major issue that i have yet to mention
all night
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
yeah i fuc*** up with this
so you need to use postgres going forward
i think i know how to change it
i've done one project with postgres
and the database is on your app
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?
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.
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
right clik on our railway.app
and then start postgresSQL ?
right click on the canvas -> database -> postgres
ok postgres alive
screenshot please
paste these into the raw editor of the web service
then save the changes with
alt + shift + enter
should i change the password immediately etc. whether it will be assigned automatically
literally paste the code block into the raw editor, do not change a single thing
ENV or JSON
env
done
have you saved?
yes
deply button ?
deploy*
save the changes with
alt + shift + enter
whoooah
assigned automatically
yeah we dont need to deploy since we are about to make code changes and that will count as the deploy
what a fantastic website
its pretty nifty
now let's check our data 😄
ok still there.
very good
we arent there yet, but i like your enthusiasm
😄
https://github.com/railwayapp-templates/django/blob/main/mysite/settings.py#L81-L90
update your settings.py with this code
ops.
File "C:\Users\Jerry\Desktop\BrainStorm\DjangoApp\settings.py", line 101, in <module>
'NAME': os.environ["PGDATABASE"],
^^
NameError: name 'os' is not defined
oh yeah, you need to import os
i figured your ide would warn you about that though :mildpanic:
should i ignore it ?
ok
no, you need to import os
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 ?
what do you mean?
deleting this
that will disapear automatically when the new deployment goes through
it happened as you said
:HAHAHA:
app not working
hahaha
figured, you need to run migrations
ok
i know how to do it
where we have app terminal now ?
your new Procfile should be
nope, railway doesnt provide ssh access to the container
ok so just replace the line in Procfile
do this and next commit
yeah i think this is all thats needed, you will just have to find a way to move your data over from sqlite
maybe tommorow i will finde a way to make a "PUT" method in the database
task for another day
nope, still not woring
theres no data in the database
i cant see how it could work
that mean migration didnt work
oh, send the deploy logs
send the build logs too
you have the start command being overwritten somewhere, check your service settings
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
doing it in the start command is fine too
have you checked?
yeah, but i don't see anything that should border us
creating apss in Django is based on just adding functionalities to exsisting framework
do you have a start command set in the service settings?
what do you exacly mean
the command im runing server ?
if i want to start it up locally ?
please look into the railway service settings, do you have a start command set there? (yes/no)
i'm looking from one place to another in our project settings but i don't see any start command set
we talk about this page yes ?
nope, look in the service settings
first open the service, then click settings
this one ?
you opened your account settings
ok our webapp setings
go back to the project, open the service, and then click settings
remove it
confirmed
click deploy if you haven't already
done
did stuff fail?
"deploying"
ok done
railway error : Application failed to respond
deploy logs please
hmm, what went wrong if everything was good
i settings app DIR is corect
ok ok
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
what do you think. typing : STATIC_ROOT = 'static/'
will work ?
ok
didnt the whitenose docs tell you what to set?
building webapp again
i guess you have around 5 kids because you are patience like monk man 😄
app is working
app works but without any data, I think the rest is up to you now eh?
https://web-production-bf8e.up.railway.app
do you se my post
in the middle of the app
with blue avatar
?
yeah
yeah i see the post
Is something i can do for you
anything ?
i dont need anything in return
i hope you gonna become at least team leader in this company
I don't even work for them lol
how this is possible
not qualified haha
im jumping off a cliff
:HAHAHA:
alright let's not say that even as a joke please
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
haha I appreciate that
can i somehow save this conversation ?
it's not going anywhere
i thing i will need it sooner or later
fuck
just copy the link, no one is going to delete it
it's been a loong day
do you work as a programist ?
in any other company ?
nope
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
you've done more than me in that regard, I've never created anything as complex as the app you just showed me
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
only problem, i dont much like python 🤣
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.
same to you, any railway questions, open a help thread
i started the day at 5am 10h work then coding and now its 3am
that how my live looks like :HAHAHA:
very nice
thanks for the train!
hey can i dm you for a django related favor?
@OPJerry tag for viz
Yes
@Brody add me to firendlist
haha my bad, forgot about that setting