#Railway deploying django help wanted!

101 messages · Page 1 of 1 (latest)

full marten
#

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?

delicate mistBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

rustic larkBOT
#

Project ID: 86e751b8-5900-4d54-b224-51a403c96f46

full marten
#

86e751b8-5900-4d54-b224-51a403c96f46

random whale
#

well first, don't listen to Alex, delete your dockerfile, redoploy, then give me your full build log please

full marten
random whale
#

looks like you are trying to use a windows specific package, services on railway generally use ubuntu

full marten
#

actually, i just noticed pywin32

full marten
random whale
#

yep that would be the package in question

full marten
#

let me see if that work now

random whale
#

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

full marten
random whale
#

ah cool

full marten
random whale
#

more or less yeah

full marten
#

cause i am gonna point the domain from cloudflare to railway deployment

random whale
#

do you own a domain?

full marten
#

yes.

random whale
#

who's your domain provider

full marten
#

cloudflare

random whale
#

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

full marten
#

i can't see any cname address in the settings, the domain is already set

random whale
#

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

full marten
random whale
#

all works?

full marten
#

let me see one last thing

full marten
random whale
#

do you see that from your custom domain?

full marten
#

yes.

random whale
#

then DNS has already propagated, that's an issue with your app

full marten
#

alright, let me see then

random whale
#

any errors in the deploy logs

full marten
random whale
#

oh you definitely don't want to be running a development server on railway

full marten
#

oh snap

random whale
#

do you have a Procfile?

full marten
#

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

random whale
#

you still need gunicorn

#

that hasn't changed and probably never will

full marten
#

i thought gunicorn whole idea is to keep a server running, no?

random whale
#

(he's an extremely experienced python dev)

full marten
#

noice

terse raven
#

Oi!

full marten
#

thanks for help Brody 🙂

terse raven
#

Let me read and catch up

full marten
#

take your time

random whale
#

why gunicorn necessary

terse raven
#

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

random whale
#

whats more so the "what" and not the "why"

full marten
random whale
#

dev, no problems with wanting to understand it, but regardless if you understand or not, you still need gunicorn

terse raven
#

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
    }
}

You can also look at the template for how to configure your port

https://GitHub.com/railwayapp-templates/django

GitHub

1-Click Django on Railway. Contribute to railwayapp-templates/django development by creating an account on GitHub.

full marten
random whale
#

you need it to run your app in a production environment, its as simple as that

full marten
#

like in dev mode, i run 127.0.0.1 which is the local host

random whale
#

gunicorn runs on 0.0.0.0 and environment variable PORT by default

terse raven
#

gunicorn will listen on the PORT env variable

full marten
#

that true, but isnt that local address too?
or is 0.0.0.0 a different case?

terse raven
#

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

random whale
#

all ipv4* hehe

full marten
# terse raven 0.0.0.0 binds to all network interfaces in a server environment

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.

random whale
#

thats a good enough analogy

full marten
#

wtf is this embed tho 😭

terse raven
#

Discord being dumb

full marten
#

i will re-deploy and give you a feedback!

full marten
random whale
#

dont worry about that

full marten
#

was busy for a while, i re-deployed, now i get too many redirects error

terse raven
#

Do you have your cloudflare ssl settings on “Full”

random whale
full marten
terse raven
#

If it’s anything other than “Full”, it will not work

full marten
#

well, it is Full

#

but not strict

terse raven
#

No, don’t use strict

random whale
#

django may also be a culprit for too many redirects

terse raven
#

And you used the cname address provided by railway when you added the domain?

terse raven
#

Not the railway generated domain as the target, correct?

full marten
#

the one they gave me when i set my custom domain (it was a dialog box)

terse raven
#

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

full marten
#

all good fam, thanks for your help 🙂 !

terse raven
#

Anytime

full marten
#

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.

delicate mistBOT
#

Thank you for marking this question as solved!

Question Message ID

1123174381372313670

Solution Message ID

1123465795922579567

terse raven
#

You’re good. It’s solved