R
Railway13mo ago
dev00

Railway deploying django help wanted!

when deploying my project, i get this error: ERROR: failed to solve: process "/bin/bash -ol pipefail -c python -m venv --copies /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt" did not complete successfully: exit code: 1 how do i fix it?
83 Replies
Percy
Percy13mo ago
Project ID: 86e751b8-5900-4d54-b224-51a403c96f46
dev00
dev0013mo ago
86e751b8-5900-4d54-b224-51a403c96f46
Brody
Brody13mo ago
well first, don't listen to Alex, delete your dockerfile, redoploy, then give me your full build log please
dev00
dev0013mo ago
@Brody Hello Brody, here is the full log:
Brody
Brody13mo ago
looks like you are trying to use a windows specific package, services on railway generally use ubuntu
dev00
dev0013mo ago
actually, i just noticed pywin32 i deleted this from requirements.txt
Brody
Brody13mo ago
yep that would be the package in question
dev00
dev0013mo ago
let me see if that work now
Brody
Brody13mo ago
you may have pip freezed every package on your system into the requirements.txt file, please go through that file and delete all packages you don't use in your project
dev00
dev0013mo ago
no i only freezed the one inside the virtual environment of my project
Brody
Brody13mo ago
ah cool
dev00
dev0013mo ago
i guess that indicate the deployment suceeded?
Brody
Brody13mo ago
more or less yeah
dev00
dev0013mo ago
ok, so how do i figure out the CNAME on railway? cause i am gonna point the domain from cloudflare to railway deployment
Brody
Brody13mo ago
do you own a domain?
dev00
dev0013mo ago
yes.
Brody
Brody13mo ago
who's your domain provider
dev00
dev0013mo ago
cloudflare
Brody
Brody13mo ago
perfect then go to the service settings, add your custom domain, then railway will give you the cname address, use that in the cloudflare DNS settings make sure you have set SSL/TLS mode to full in cloudflare too
dev00
dev0013mo ago
i can't see any cname address in the settings, the domain is already set
Brody
Brody13mo ago
you would have been given the cname when you added the domain send me your custom domain please, along with a screenshot of the domains in the railway service, and your DNS settings in cloudflare
dev00
dev0013mo ago
nvm, got it when i re-added the domain
Brody
Brody13mo ago
all works?
dev00
dev0013mo ago
let me see one last thing
dev00
dev0013mo ago
I guess that part of "DNS takes 72 hours to propgate"?
Brody
Brody13mo ago
do you see that from your custom domain?
dev00
dev0013mo ago
yes.
Brody
Brody13mo ago
then DNS has already propagated, that's an issue with your app
dev00
dev0013mo ago
alright, let me see then
Brody
Brody13mo ago
any errors in the deploy logs
dev00
dev0013mo ago
deployment logs
Brody
Brody13mo ago
oh you definitely don't want to be running a development server on railway
dev00
dev0013mo ago
oh snap
Brody
Brody13mo ago
do you have a Procfile?
dev00
dev0013mo ago
how did i not notice this, ok so, what the procedure here? in the old times, i used to keep the server running using gunicorn+ niginx for load balancing but I guess railway does handle the server running for me
Brody
Brody13mo ago
you still need gunicorn that hasn't changed and probably never will
dev00
dev0013mo ago
ok, let's speak in term of gunicorn, why do i need it? i thought gunicorn whole idea is to keep a server running, no?
Brody
Brody13mo ago
@Vin your expertise are required (he's an extremely experienced python dev)
dev00
dev0013mo ago
noice
MantisInABox
MantisInABox13mo ago
Oi!
dev00
dev0013mo ago
thanks for help Brody 🙂
MantisInABox
MantisInABox13mo ago
Let me read and catch up
dev00
dev0013mo ago
take your time
Brody
Brody13mo ago
why gunicorn necessary
MantisInABox
MantisInABox13mo ago
Thanks. I’m caught up. Gunicorn isn’t a process manager, it is a whole production WSGI server. If you just run your manage.py file, it will launch the dev server which is for testing, and as you can see is looking at the wrong port. With Gunicorn, it will not display error logs on the front end when people hit one, exposing not only your file structure, but also exposing a debug terminal in the browser allowing people to run exploitation code
Brody
Brody13mo ago
whats more so the "what" and not the "why"
dev00
dev0013mo ago
do you mind explaining how gunicorn handle running the server? I thought gunicorn somehow run on a local port too?
Brody
Brody13mo ago
dev, no problems with wanting to understand it, but regardless if you understand or not, you still need gunicorn
MantisInABox
MantisInABox13mo ago
I would place a railway.json file in your project root and place the following contents in it
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
You can also look at the template for how to configure your port https://GitHub.com/railwayapp-templates/django
GitHub
GitHub - railwayapp-templates/django: 1-Click Django on Railway
1-Click Django on Railway. Contribute to railwayapp-templates/django development by creating an account on GitHub.
dev00
dev0013mo ago
yeah, i will create the procfile and add the gunicorn command, but i really want to understand why i need it for the future
Brody
Brody13mo ago
you need it to run your app in a production environment, its as simple as that
dev00
dev0013mo ago
Thanks, i will look it up true, but what kind of address does gunicorn run in this case? like in dev mode, i run 127.0.0.1 which is the local host
Brody
Brody13mo ago
gunicorn runs on 0.0.0.0 and environment variable PORT by default
MantisInABox
MantisInABox13mo ago
gunicorn will listen on the PORT env variable
dev00
dev0013mo ago
that true, but isnt that local address too? or is 0.0.0.0 a different case?
MantisInABox
MantisInABox13mo ago
It’s not a loop back address like 127.0.0.1 0.0.0.0 binds to all network interfaces in a server environment
Brody
Brody13mo ago
all ipv4* hehe
dev00
dev0013mo ago
just had a good read here: https://www.howtogeek.com/225487/what-is-the-difference-between-127.0.0.1-and-0.0.0.0/ I guess 0.0.0.0 work as a placeholder address, which let all addresses access it
How-To Geek
Most of us have heard of ‘127.0.0.1 and 0.0.0.0’ but have probably not given much thought to them, but if both actually seem to point to the same location, then what is the actual difference between the two? Today’s SuperUser Q&A post helps clear things up for a confused reader.
Brody
Brody13mo ago
thats a good enough analogy
dev00
dev0013mo ago
wtf is this embed tho 😭
MantisInABox
MantisInABox13mo ago
Discord being dumb
dev00
dev0013mo ago
i will re-deploy and give you a feedback!
dev00
dev0013mo ago
why is $schema a not allowed property in json?
Brody
Brody13mo ago
dont worry about that
dev00
dev0013mo ago
was busy for a while, i re-deployed, now i get too many redirects error
MantisInABox
MantisInABox13mo ago
Do you have your cloudflare ssl settings on “Full”
Brody
Brody13mo ago
remember when i said this lol
dev00
dev0013mo ago
let me check, but last time it was
MantisInABox
MantisInABox13mo ago
If it’s anything other than “Full”, it will not work
dev00
dev0013mo ago
dev00
dev0013mo ago
well, it is Full but not strict
MantisInABox
MantisInABox13mo ago
No, don’t use strict
Brody
Brody13mo ago
django may also be a culprit for too many redirects
MantisInABox
MantisInABox13mo ago
And you used the cname address provided by railway when you added the domain?
dev00
dev0013mo ago
100%
MantisInABox
MantisInABox13mo ago
Not the railway generated domain as the target, correct?
dev00
dev0013mo ago
yes the one they gave me when i set my custom domain (it was a dialog box)
MantisInABox
MantisInABox13mo ago
Yes, that’s the one you should be using. Unfortunately I’m not on the computer for another 4 1/2 hours, so I can’t really help troubleshoot too much more
dev00
dev0013mo ago
all good fam, thanks for your help 🙂 !
MantisInABox
MantisInABox13mo ago
Anytime
dev00
dev0013mo ago
alright i fixed everything i had set SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') in settings.py for django, which fixed the redirect error.
MantisInABox
MantisInABox13mo ago
You’re good. It’s solved
Brody
Brody13mo ago
woohoo