I am deploying my django project using railway and I am encountering some errors
I am only a student so please bear with me. I am deploying a django project with xhtml2pdf for report generation. It requires the pycairo package that needs some packages to be installed so I made a nixpacks.toml that contains the ff as per pycairo's documentation:
[phases.setup]
aptPkgs = ["...", "libcairo2-dev", "pkg-config", "python3-dev"]
however, I am faced with this error (see attached image). I've been stucked here for hours looking for a solution. Thank you!
51 Replies
Project ID:
e6023080-277d-4fb8-a397-5c7f215b907d
e6023080-277d-4fb8-a397-5c7f215b907d
unfortunately I've never had any luck using nixpacks as a builder when I needed to install those apt packages, I've always had to write a dockerfile, which id be happy to do for you if you could share your repo with me
sure, and how exactly can I do that?
send the link to your repo
i'll dm you the link. thank you very much!
alright but keep in mind for the future that it's against server rules to do such, it's fine this time though
i'm sorry, i am new here. i'll keep that in mind next time.
no worries
I see the link, but we will continue the conversation here
please make the repo public or else I won't be able to access it
yup i just realized that
its public now
good thing you've sent it to me privately, you have hardcoded your database credentials in settings.py
same with your aws credentials
before I write the dockerfile, please set everything sensitive as a service variable
https://docs.railway.app/develop/variables#service-variables
and make sure the database credentials are reference variables
https://docs.railway.app/develop/variables#reference-variables
let me know when that's done and I'll look at the repo again
yeah i know, thats what I was saying to my other group mate. but im gonna wok on it now. thank you for your patience!
once you are using environment variables in your code, use railway's cli to run your app locally with all the service variables automatically available
https://docs.railway.app/develop/cli
the command would be
railway run <whatever command you normally use to start your app locally>
to be clear, do I just input the credentials for our aws & database here? sorry i'm asking many questions.
more of less, but that's why I've sent those two links to the variables page, please do read them carefully
can I make an .env file instead? I can't install railway CLI for some reason.
an .env file is what we are trying to avoid more or less, thats still storing sensitive information in plain text
I can't install railway CLI for some reason.please tell me more
when I type npm i -g @railway/cli on my terminal this appears
i dont see any errors?
did this mean its downloaded?
i assume so, why not try it
yep its installed
perfect, continue on!
assuming that my environment variable for a certain access key is named ACCESS_KEY1, do i just put AWS_ACCESS_KEY_ID = 'ACCESS_KEY1'
if its named ACCESS_KEY1, then you put ACCESS_KEY1 = the key
NAME = VALUE
this is the format, variable name = variable value
i still don't get it 😢 . i'm sorry my brain is disintegrating as we speak
have you read the docs page i linked?
yep, i'm just confused
on what specifically?
on this, like what exactly is NAMESPACE? or if I have to use this? I am sorry if i have many questions, i'm still new to this but i really want to learn.
for the database stuff railway will auto complete that stuff for you, theres a screenshot showing that in action, for everything else, its as simple as this
then what should I put in my settings.py?
oh my bad, sounded like you knew what to do there so i didnt wanna bother you by explaining it again
heres an example
https://github.com/railwayapp-templates/django/blob/main/mysite/settings.py#L81-L90
same kinda thing for your aws key stuff too
oh and same for the email stuff too
i have done it, but an error occured on my local server, i believe my cloudfront key is causing the error. nevertheless, i have set the environment keys.
push the code so i can check?
its pushed already
needs to be an environment variable https://github.com/NhoryJames/adopt_a_friend/blob/main/adopt_a_friend/settings.py#L15
use the same engine that the code i sent does https://github.com/NhoryJames/adopt_a_friend/blob/main/adopt_a_friend/settings.py#L90
needs to be an environment variable https://github.com/NhoryJames/adopt_a_friend/blob/main/adopt_a_friend/settings.py#L118
i fixed it and pushed it on github
looking
code side of things looks good, are you sure you have all the applicable service variables set on railway?
yep
thank you for your patience, really
youve got the database variables setup as referance variables, and not just their raw values?
yep just like this one
and does it render properly when you click the eye icon?
yup
cool, will send over a pr
hi! if i don't respond immediately that means i fell asleep (its 3:30am here). please know that I am very thankful for your help and patience ❤️
no worries!
i did send a pr https://github.com/NhoryJames/adopt_a_friend/pull/1/
i have merged it, do I follow this https://docs.railway.app/deploy/dockerfiles?
nope, the dockerfile is picked up automatically
its deployed now!
just need to fix some of this errors and we're good to go. thank you so much ❤️ .
no problem, glad to hear it