Nixpack build error with Django app
Hi there, I am a former Heroku user trying to migrate to a Nixpack buildpack given the foreseen discontinuation of the Heroku's, but I am receiving the following error with my Django app:
124 Replies
My Dockerfile works fine locally. How should I install the packages that will help psycopg2 installation go through without errors?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
My Dockerfile is tailored for the local environment. I think my project setup has to be overhauled in order to make it work with Nixpacks remotely. So I am starting from scratch. In order to have Python requirements install on Heroku, I used to have a requirements.txt in the project root with the dependencies needed for the remote Heroku environment only. Is this how it is supposed to be done with Nixpacks as well? Also, is there a Nixpack-compatible Python project example available anywhere?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Thanks. The root requirements.txt thing is bugging me though. I thought the Nixpack buildpack was looking into the Dockerfile only, but it is actually looking into the root requirements.txt first and tries to install those. I don't see this covered in the guide at all.
If you have a Dockerfile it should use that
If it's in not the root, you'll wanna set the root directory to where the Dockerfile is is
Or set Variable DOCKERFILE_PATH to the dockerfiles path
My Dockerfile is in the root indeed, but the requirements.txt also is, and Nixpack is somehow preferring the latter.
Fucky. It should pickup Dockerfile first
Is it named correctly?
Dockerfile
Dockerfile
Capitals matter
indeed
Mmmm
ProjectID?
9a8cdddf-87aa-4caf-848a-69fb07710946
I am wondering, does Nixpack support multistaging? Or should I go for using separate Dockerfiles for the local vs remote envs?
Could you elaborate?
What would you need to change in your Dockerfile for local vs remote
Locally I am using dependencies (mainly for testing and debugging) that are of no use remotely.
Gotchya
We've just added multiple provider support to Nixpacks. So, in the future yes but for now no
I see
Will have a look I'm about 10m when I'm home
Ok, thank you.
uhh it appears to be using your dockerfile
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
Mmh, when I do
sudo nixpack build .
it seems to get the requirements.txt
instead. Anyway, I am taking it out for good.
A skeleton Django project built with a view to using the Nixpack buildpack would be great to inspect, with an example pyproject.toml
and an example artifact the sudo nixpack build .
command produces at the end of the build.Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Thanks, but I can't. I have an ARM64 CPU. I'll have to work on my Dockerfile.
Ok, back at it again. Nixpack building is soo slow. Any clue as to why it's behaving like this?
FYI, I am peaking at 20 mb/s downloading games off of Steam.
Likely steams APIs being slow. Network looks fine here
?
Oh are you running this locally?
Sorry I thought it was on the builder
Unsure then could be GCR
Uhm ok, it should take like a few seconds to download 40 megs
but I was over 10 mins
Unsure sadly we can't debug local stuff
I am wondering, what it supposed to happen at the end of the build? What should be produced?
An image
Is that it? A Docker image?
Yes
And that image is pushed remotely at the end of the build?
Sorry, I don't get how that's supposed to work.
No
It's on your local
So you can test it however you'd like
I am already producing an image with my own docker compose
That's not usable on Railway
I don't need to do
nixpack build .
Ok
Do you believe it would be possible to only have those files in the repo without doing nixpack build .
?Which files
Because from here it looks like an unnecessary chore for those having a docker compose
producing a set of images
You can use a Dockerfile
It looks like an unnecessary chore to have another image
just for Railway
or am I missing something?
What's your issue?
You said it's not usable on Railway
it means there's something more in that image produced by
nixpack build .
that doing docker compose build
doesn't do.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.
Here's a django example
I have a couple:
1) nixpack is not working at the moment as you can see
2) I feel like I will be polluting my local system with docker images that'll be used just by Railway
What are you trying to do here
Deploy a Django application correct?
Yes
Great
thanks for the link
That looks like a vanilla Django project with a Heroku Procfile
I am mentioning Heroku because it's where I was before
You can delete the Heroku procfile if you'd like
Ok
I don't see a Dockerfile in there
That's because there isn't one
Ok
so what's the screenshot above referring to?
The repo builds just fine and is Django
Isn't it supposed to be feeding from a local Dockerfile?
No
Uhm, ok
You can either write a Dockerfile, or have Nixpacks run detection on your code
So you don't need a local Dockerfile
You do not
Ok
UNLESS, you want to write one
Ok
In which case we also support that
I'd like to keep a Dockerfile.local but maybe I don't need a Dockerfile for Nixpack
(btw, thanks for taking the time to give support)
You are very welcome
In this case, I'd make sure it's named exactly like that
Otherwise, Railway will try and use it
Ok
And Railway will recognize a requirements.txt file placed in the root only, correct?
In your root directory. Which you can set, in settings
So if you have a monorepo and it's
backend/requirements.txt
, set root to backend/
When you say "set root in settings", which settings are you talking about?
Service -> Settings -> Root Directory
Uhm ok maybe I don't need one
Anyways, what you meant before is that
nixpack build .
is just for local development?No?
Well
Sorta in a way I suppose
You can run it locally to test Nixpacks
It's what we run when you build stuff in production using nixpacks
Yeah
you advise to do
nixpack build ,
locally to test out the project before deploying. But it's not mandatory to run that command in order to deploy.Shouldn't need to
Just trigger the deploy and see the logs
Should be fast enough to do that
Thanks, I understand the philosophy behind nixpacks better now.
I managed to deploy the app, but for some reason statics are not being served
it's 404 all over the place
How come in the example Django repo you have psycopg2 (and not psycopg2-binary) as a requirement, but when I push it it fails with
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I do
just checked
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Sure
My root requirements.txt is just saying:
I am sharing the actual remote.txt contents in a minute
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Done. It's redeploying... let's see what happens.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
It's taking more than 10 mins now
but it is indeed doing stuff
Ok it appears to have gone past the postgres deps build
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Ok great
thanks
I think it's almost done
let's see if it goes through
What dep do you have that needs PG?
So we can add it to Nixpacks
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
We scan for that tho :/
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
O
Ok deploy successful
Thank you
Only problem now is
statics are not served, but nothing changed on my side
I see 404s for every static
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
not really
I could invite you though
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Done
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
mmh maybe I should be doing
python manage.py collectstatic
somewhere
not sure where though.Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Thanks. I would like to do without the Procfile if possible
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Do you think the "release" command could be specified somewhere but in the Procfile?
yeah
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Thanks. What should be as the build command?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
should I just put
python manage.py migrate --no-input
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
ok great
Thank you guys, it's working great now.
Is a requirements.txt with generated hashes supported?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I am redeploying now, will tell you shortly if it works out of the box.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Don't worry, you've been extremely helpful
Cooper and you, that is
💯
So you were saying I might override NIXPACKS_INSTALL_CMD
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I tried both pip3 and pip, but it says command not found
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Sorry, like this it should be better and in full
Let me know what you find out. Thank you!
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Thank you!
Found anything?