R
Railway13mo ago
Nhory

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!
No description
51 Replies
Percy
Percy13mo ago
Project ID: e6023080-277d-4fb8-a397-5c7f215b907d
Nhory
NhoryOP13mo ago
e6023080-277d-4fb8-a397-5c7f215b907d
Brody
Brody13mo ago
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
Nhory
NhoryOP13mo ago
sure, and how exactly can I do that?
Brody
Brody13mo ago
send the link to your repo
Nhory
NhoryOP13mo ago
i'll dm you the link. thank you very much!
Brody
Brody13mo ago
alright but keep in mind for the future that it's against server rules to do such, it's fine this time though
Nhory
NhoryOP13mo ago
i'm sorry, i am new here. i'll keep that in mind next time.
Brody
Brody13mo ago
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
Nhory
NhoryOP13mo ago
yup i just realized that its public now
Brody
Brody13mo ago
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
Nhory
NhoryOP13mo ago
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!
Brody
Brody13mo ago
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>
Nhory
NhoryOP13mo ago
to be clear, do I just input the credentials for our aws & database here? sorry i'm asking many questions.
No description
Brody
Brody13mo ago
more of less, but that's why I've sent those two links to the variables page, please do read them carefully
Nhory
NhoryOP13mo ago
can I make an .env file instead? I can't install railway CLI for some reason.
Brody
Brody13mo ago
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
Nhory
NhoryOP13mo ago
when I type npm i -g @railway/cli on my terminal this appears
No description
Brody
Brody13mo ago
i dont see any errors?
Nhory
NhoryOP13mo ago
did this mean its downloaded?
Brody
Brody13mo ago
i assume so, why not try it
Nhory
NhoryOP13mo ago
yep its installed
Brody
Brody13mo ago
perfect, continue on!
Nhory
NhoryOP13mo ago
assuming that my environment variable for a certain access key is named ACCESS_KEY1, do i just put AWS_ACCESS_KEY_ID = 'ACCESS_KEY1'
Brody
Brody13mo ago
if its named ACCESS_KEY1, then you put ACCESS_KEY1 = the key NAME = VALUE this is the format, variable name = variable value
Nhory
NhoryOP13mo ago
i still don't get it 😢 . i'm sorry my brain is disintegrating as we speak
Brody
Brody13mo ago
have you read the docs page i linked?
Nhory
NhoryOP13mo ago
yep, i'm just confused
Brody
Brody13mo ago
on what specifically?
Nhory
NhoryOP13mo ago
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.
No description
Brody
Brody13mo ago
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
No description
Nhory
NhoryOP13mo ago
then what should I put in my settings.py?
Brody
Brody13mo ago
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
Nhory
NhoryOP13mo ago
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.
Brody
Brody13mo ago
push the code so i can check?
Nhory
NhoryOP13mo ago
its pushed already
Nhory
NhoryOP13mo ago
i fixed it and pushed it on github
Brody
Brody13mo ago
looking code side of things looks good, are you sure you have all the applicable service variables set on railway?
Nhory
NhoryOP13mo ago
yep thank you for your patience, really
Brody
Brody13mo ago
youve got the database variables setup as referance variables, and not just their raw values?
Nhory
NhoryOP13mo ago
yep just like this one
No description
Brody
Brody13mo ago
and does it render properly when you click the eye icon?
Nhory
NhoryOP13mo ago
yup
Brody
Brody13mo ago
cool, will send over a pr
Nhory
NhoryOP13mo ago
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 ❤️
Brody
Brody13mo ago
Nhory
NhoryOP13mo ago
i have merged it, do I follow this https://docs.railway.app/deploy/dockerfiles?
Railway Docs
Dockerfiles | Railway Docs
Documentation for Railway
Brody
Brody13mo ago
nope, the dockerfile is picked up automatically
Nhory
NhoryOP13mo ago
its deployed now! just need to fix some of this errors and we're good to go. thank you so much ❤️ .
Brody
Brody13mo ago
no problem, glad to hear it
Want results from more Discord servers?
Add your server