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
Niccolò
NiccolòOP3y ago
My Dockerfile works fine locally. How should I install the packages that will help psycopg2 installation go through without errors?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
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.
JustJake
JustJake3y ago
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
Niccolò
NiccolòOP3y ago
My Dockerfile is in the root indeed, but the requirements.txt also is, and Nixpack is somehow preferring the latter.
JustJake
JustJake3y ago
Fucky. It should pickup Dockerfile first Is it named correctly? Dockerfile
Niccolò
NiccolòOP3y ago
Dockerfile
JustJake
JustJake3y ago
Capitals matter
Niccolò
NiccolòOP3y ago
indeed
JustJake
JustJake3y ago
Mmmm ProjectID?
Niccolò
NiccolòOP3y ago
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?
JustJake
JustJake3y ago
Could you elaborate? What would you need to change in your Dockerfile for local vs remote
Niccolò
NiccolòOP3y ago
Locally I am using dependencies (mainly for testing and debugging) that are of no use remotely.
JustJake
JustJake3y ago
Gotchya We've just added multiple provider support to Nixpacks. So, in the future yes but for now no
Niccolò
NiccolòOP3y ago
I see
JustJake
JustJake3y ago
Will have a look I'm about 10m when I'm home
Niccolò
NiccolòOP3y ago
Ok, thank you.
JustJake
JustJake3y ago
uhh it appears to be using your dockerfile
JustJake
JustJake3y ago
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
Niccolò
NiccolòOP3y ago
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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
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?
[+] Building 621.4s (4/14)
=> [internal] load build definition from Dockerfile 0.0s
[+] Building 621.5s (5/14)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.08kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for ghcr.io/railwayapp/nixpacks:debian-16654 0.4s
=> [internal] load build context 0.4s
=> => transferring context: 25.57MB 0.4s
=> CANCELED [stage-0 1/10] FROM ghcr.io/railwayapp/nixpacks:debian-16 621.0s
=> => resolve ghcr.io/railwayapp/nixpacks:debian-1665446966@sha256:48088 0.0s
=> => sha256:4ce525b9479139c4ce71ba043d4d15360ae04216 29.77MB / 29.77MB 21.2s
=> => sha256:48088795aef10698578d862349bf230f0ace63c978f 1.05kB / 1.05kB 0.0s
=> => sha256:ba70d21f951d0969e1375f9320cd8578b2eda8e9a04904f 953B / 953B 0.0s
=> => sha256:a2593eb06f40909eccfe277c5d466d69938da501a67 3.84kB / 3.84kB 0.0s
=> => sha256:a9fe95647e78b5516c7e2327355b6996e2ea295 22.02MB / 30.05MB 621.0s
=> => sha256:adbc07ad76c8682da11b96475f4ed9dcbab30d78 7.34MB / 43.03MB 621.0s
[+] Building 621.4s (4/14)
=> [internal] load build definition from Dockerfile 0.0s
[+] Building 621.5s (5/14)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 1.08kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for ghcr.io/railwayapp/nixpacks:debian-16654 0.4s
=> [internal] load build context 0.4s
=> => transferring context: 25.57MB 0.4s
=> CANCELED [stage-0 1/10] FROM ghcr.io/railwayapp/nixpacks:debian-16 621.0s
=> => resolve ghcr.io/railwayapp/nixpacks:debian-1665446966@sha256:48088 0.0s
=> => sha256:4ce525b9479139c4ce71ba043d4d15360ae04216 29.77MB / 29.77MB 21.2s
=> => sha256:48088795aef10698578d862349bf230f0ace63c978f 1.05kB / 1.05kB 0.0s
=> => sha256:ba70d21f951d0969e1375f9320cd8578b2eda8e9a04904f 953B / 953B 0.0s
=> => sha256:a2593eb06f40909eccfe277c5d466d69938da501a67 3.84kB / 3.84kB 0.0s
=> => sha256:a9fe95647e78b5516c7e2327355b6996e2ea295 22.02MB / 30.05MB 621.0s
=> => sha256:adbc07ad76c8682da11b96475f4ed9dcbab30d78 7.34MB / 43.03MB 621.0s
FYI, I am peaking at 20 mb/s downloading games off of Steam.
JustJake
JustJake3y ago
Likely steams APIs being slow. Network looks fine here
Niccolò
NiccolòOP3y ago
?
JustJake
JustJake3y ago
Oh are you running this locally? Sorry I thought it was on the builder Unsure then could be GCR
Niccolò
NiccolòOP3y ago
Uhm ok, it should take like a few seconds to download 40 megs but I was over 10 mins
JustJake
JustJake3y ago
Unsure sadly we can't debug local stuff
Niccolò
NiccolòOP3y ago
I am wondering, what it supposed to happen at the end of the build? What should be produced?
JustJake
JustJake3y ago
An image
Niccolò
NiccolòOP3y ago
Is that it? A Docker image?
JustJake
JustJake3y ago
Yes
Niccolò
NiccolòOP3y ago
And that image is pushed remotely at the end of the build? Sorry, I don't get how that's supposed to work.
JustJake
JustJake3y ago
No It's on your local So you can test it however you'd like
Niccolò
NiccolòOP3y ago
I am already producing an image with my own docker compose
JustJake
JustJake3y ago
That's not usable on Railway
Niccolò
NiccolòOP3y ago
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 .?
JustJake
JustJake3y ago
Which files
Niccolò
NiccolòOP3y ago
Because from here it looks like an unnecessary chore for those having a docker compose producing a set of images
JustJake
JustJake3y ago
You can use a Dockerfile
Niccolò
NiccolòOP3y ago
It looks like an unnecessary chore to have another image just for Railway or am I missing something?
JustJake
JustJake3y ago
What's your issue?
Niccolò
NiccolòOP3y ago
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.
JustJake
JustJake3y ago
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.
JustJake
JustJake3y ago
Here's a django example
Niccolò
NiccolòOP3y ago
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
JustJake
JustJake3y ago
What are you trying to do here Deploy a Django application correct?
Niccolò
NiccolòOP3y ago
Yes
JustJake
JustJake3y ago
Great
Niccolò
NiccolòOP3y ago
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
JustJake
JustJake3y ago
You can delete the Heroku procfile if you'd like
Niccolò
NiccolòOP3y ago
Ok
JustJake
JustJake3y ago
Niccolò
NiccolòOP3y ago
I don't see a Dockerfile in there
JustJake
JustJake3y ago
That's because there isn't one
Niccolò
NiccolòOP3y ago
Ok so what's the screenshot above referring to?
JustJake
JustJake3y ago
The repo builds just fine and is Django
Niccolò
NiccolòOP3y ago
Isn't it supposed to be feeding from a local Dockerfile?
JustJake
JustJake3y ago
No
Niccolò
NiccolòOP3y ago
Uhm, ok
JustJake
JustJake3y ago
You can either write a Dockerfile, or have Nixpacks run detection on your code
Niccolò
NiccolòOP3y ago
So you don't need a local Dockerfile
JustJake
JustJake3y ago
You do not
Niccolò
NiccolòOP3y ago
Ok
JustJake
JustJake3y ago
UNLESS, you want to write one
Niccolò
NiccolòOP3y ago
Ok
JustJake
JustJake3y ago
In which case we also support that
Niccolò
NiccolòOP3y ago
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)
JustJake
JustJake3y ago
You are very welcome In this case, I'd make sure it's named exactly like that Otherwise, Railway will try and use it
Niccolò
NiccolòOP3y ago
Ok And Railway will recognize a requirements.txt file placed in the root only, correct?
JustJake
JustJake3y ago
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/
Niccolò
NiccolòOP3y ago
When you say "set root in settings", which settings are you talking about?
JustJake
JustJake3y ago
Service -> Settings -> Root Directory
Niccolò
NiccolòOP3y ago
Uhm ok maybe I don't need one Anyways, what you meant before is that nixpack build . is just for local development?
JustJake
JustJake3y ago
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
Niccolò
NiccolòOP3y ago
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.
JustJake
JustJake3y ago
Shouldn't need to Just trigger the deploy and see the logs Should be fast enough to do that
Niccolò
NiccolòOP3y ago
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
#12 13.65 Error: pg_config executable not found.
#12 13.65
#12 13.65 pg_config is required to build psycopg2 from source. Please add the directory
#12 13.65 containing pg_config to the $PATH or specify the full executable path with the
#12 13.65 option:
#12 13.65
#12 13.65 python setup.py build_ext --pg-config /path/to/pg_config build ...
#12 13.65
#12 13.65 or with the pg_config option in 'setup.cfg'.
#12 13.65
#12 13.65 If you prefer to avoid building psycopg2 from source, please install the PyPI
#12 13.65 'psycopg2-binary' package instead.
#12 13.65 Error: pg_config executable not found.
#12 13.65
#12 13.65 pg_config is required to build psycopg2 from source. Please add the directory
#12 13.65 containing pg_config to the $PATH or specify the full executable path with the
#12 13.65 option:
#12 13.65
#12 13.65 python setup.py build_ext --pg-config /path/to/pg_config build ...
#12 13.65
#12 13.65 or with the pg_config option in 'setup.cfg'.
#12 13.65
#12 13.65 If you prefer to avoid building psycopg2 from source, please install the PyPI
#12 13.65 'psycopg2-binary' package instead.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
I do just checked
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
Sure My root requirements.txt is just saying:
-r requirements/remote.txt
-r requirements/remote.txt
I am sharing the actual remote.txt contents in a minute
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
Done. It's redeploying... let's see what happens.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
Ok great thanks I think it's almost done let's see if it goes through
JustJake
JustJake3y ago
What dep do you have that needs PG? So we can add it to Nixpacks
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
JustJake
JustJake3y ago
We scan for that tho :/
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
JustJake
JustJake3y ago
O
Niccolò
NiccolòOP3y ago
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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
not really I could invite you though
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
Done
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
/opt/venv/lib/python3.8/site-packages/whitenoise/base.py:115: UserWarning: No directory at: /app/static/
warnings.warn(f"No directory at: {root}")
/opt/venv/lib/python3.8/site-packages/whitenoise/base.py:115: UserWarning: No directory at: /app/static/
warnings.warn(f"No directory at: {root}")
/opt/venv/lib/python3.8/site-packages/whitenoise/base.py:115: UserWarning: No directory at: /app/static/
warnings.warn(f"No directory at: {root}")
/opt/venv/lib/python3.8/site-packages/whitenoise/base.py:115: UserWarning: No directory at: /app/static/
warnings.warn(f"No directory at: {root}")
/opt/venv/lib/python3.8/site-packages/whitenoise/base.py:115: UserWarning: No directory at: /app/static/
warnings.warn(f"No directory at: {root}")
/opt/venv/lib/python3.8/site-packages/whitenoise/base.py:115: UserWarning: No directory at: /app/static/
warnings.warn(f"No directory at: {root}")
mmh maybe I should be doing python manage.py collectstatic somewhere not sure where though.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
Thanks. I would like to do without the Procfile if possible
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
Do you think the "release" command could be specified somewhere but in the Procfile? yeah
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
Thanks. What should be as the build command?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
should I just put python manage.py migrate --no-input
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
ok great Thank you guys, it's working great now. Is a requirements.txt with generated hashes supported?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
I am redeploying now, will tell you shortly if it works out of the box.
#12 20.00 ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
#12 20.00 backports.zoneinfo from https://files.pythonhosted.org/packages/1a/ab/3e941e3fcf1b7d3ab3d0233194d99d6a0ed6b24f8f956fc81e47edc8c079/backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl#sha256=7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9 (from django==4.1.2->-r requirements/remote.txt (line 205))
#12 20.00 ERROR: In --require-hashes mode, all requirements must have their versions pinned with ==. These do not:
#12 20.00 backports.zoneinfo from https://files.pythonhosted.org/packages/1a/ab/3e941e3fcf1b7d3ab3d0233194d99d6a0ed6b24f8f956fc81e47edc8c079/backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl#sha256=7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9 (from django==4.1.2->-r requirements/remote.txt (line 205))
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
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
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
I tried both pip3 and pip, but it says command not found
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
Sorry, like this it should be better and in full Let me know what you find out. Thank you!
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Niccolò
NiccolòOP3y ago
Thank you! Found anything?
Want results from more Discord servers?
Add your server