Docker Build Error
Hello, how do you do?
I am getting the following error when deploying my Django project:
Dockerfile:21
-------------------
19 | RUN printf '\nPATH=/opt/venv/bin:$PATH' >> /root/.profile
20 | COPY . /app/.
21 | >>> RUN --mount=type=cache,id=s/12ad632d-3245-4503-b551-fa89e82b6a0e-/root/cache/pip,target=/root/.cache/pip python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt
22 |
23 |
-------------------
ERROR: failed to solve: process "/bin/bash -ol pipefail -c python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt" did not complete successfully: exit code: 1
Error: Docker build failed
Please help
129 Replies
Project ID:
12ad632d-3245-4503-b551-fa89e82b6a0e
full build logs please
#11 11.83 creating build/lib.linux-x86_64-cpython-311/cairo
#11 11.83 copying cairo/init.py -> build/lib.linux-x86_64-cpython-311/cairo
#11 11.83 copying cairo/init.pyi -> build/lib.linux-x86_64-cpython-311/cairo
#11 11.83 copying cairo/py.typed -> build/lib.linux-x86_64-cpython-311/cairo
#11 11.83 running build_ext
#11 11.83 Package cairo was not found in the pkg-config search path.
#11 11.83 Perhaps you should add the directory containing `cairo.pc'
#11 11.83 to the PKG_CONFIG_PATH environment variable
#11 11.83 No package 'cairo' found
#11 11.83 Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.
#11 11.83 [end of output]
#11 11.83
#11 11.83 note: This error originates from a subprocess, and is likely not a problem with pip.
#11 11.83 ERROR: Failed building wheel for pycairo
#11 11.83 Failed to build pycairo
#11 11.83 ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects
#11 11.85
#11 11.85 [notice] A new release of pip available: 22.3.1 -> 23.1.2
#11 11.85 [notice] To update, run: pip install --upgrade pip
#11 ERROR: process "/bin/bash -ol pipefail -c python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt" did not complete successfully: exit code: 1
-----
[stage-0 7/8] RUN --mount=type=cache,id=s/12ad632d-3245-4503-b551-fa89e82b6a0e-/root/cache/pip,target=/root/.cache/pip python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt:#11 11.83 Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1. #11 11.83 [end of output] #11 11.83 #11 11.83 note: This error originates from a subprocess, and is likely not a problem with pip. #11 11.83 ERROR: Failed building wheel for pycairo #11 11.83 Failed to build pycairo #11 11.83 ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects #11 11.85 #11 11.85 [notice] A new release of pip available: 22.3.1 -> 23.1.2 #11 11.85 [notice] To update, run: pip install --upgrade pip ----- Dockerfile:21 ------------------- 19 | RUN printf '\nPATH=/opt/venv/bin:$PATH' >> /root/.profile 20 | COPY . /app/. 21 | >>> RUN --mount=type=cache,id=s/12ad632d-3245-4503-b551-fa89e82b6a0e-/root/cache/pip,target=/root/.cache/pip python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt 22 | 23 | ------------------- ERROR: failed to solve: process "/bin/bash -ol pipefail -c python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt" did not complete successfully: exit code: 1 Error: Docker build failed
in the future please send logs as .txt files
Oh, let me try....
add this as a nixpacks.toml file to your project
untested, but let me know how that goes
To the root directory of the django project?
correct
It says that "nixpacks.toml" is not a valid name for a file or folder...
lmfao yes it is
There?
thats not all of what i sent
There?
looks good
Let me commit and push and redeploy, okay?
keep in mind, this is untested, i dont have anything to test with so i am just making assumptions
Okay, now building... let's see how it goes...
Would you like to check that out, please?
full build logs please
That's better?
try this instead
In the same "nixpacks.toml" file?
replace its contents with that
Okay... trying...
I'm I doing something wrong maybe? Or are my modules requiring an upgrade/downgrade?
do you have a repo (no you arent doing anything wrong)
Yes, I can share the repo...
please do
also send me the table at the very top of your build logs
its private
╔═══════════════════════════════ Nixpacks v1.5.1 ══════════════════════════════╗
║ setup │ python311, postgresql, gcc, libcairo2-dev ║
║──────────────────────────────────────────────────────────────────────────────║
║ install │ python -m venv /opt/venv && . /opt/venv/bin/activate && pip ║
║ │ install -r requirements.txt ║
║──────────────────────────────────────────────────────────────────────────────║
║ start │ gunicorn kafu_online_admission_system.wsgi --log-file - ║
╚══════════════════════════════════════════════════════════════════════════════╝
That table?
Yes, it's private
its of no help to me if its private lol
It's public now
thank you
What more should I do?
work on switching to one of the databases railway provides
How would I do that?
you use sqlite, that wont work on railway since they dont have persistent storage, thus your whole database will get replaced on every deployment
Um, will that happen automatically?
every time you make a change to the github repo
I don't think I have a problem with the database... provided it creates the tables/models just as I have described them in the Django project... or how would it work?
do you write to the database when your app is deployed?
I don't think so... I haven't done anything to the database...
Would you like to check out the project on GitHub and maybe see where the mishap is?
already working on it
okay you have been warned
do you actually use pycairo in your project
Haha... I'm so new to this, I don't even think I have understood the warning really.
I don't think I use it, no.
delete the nixpacks.toml file
remove pycairo and rlPyCairo from your requirements.txt file
let me know how that goes
do I need to uninstall it via pip?
just remove it from the file with your text editor
Then I pip freeze or I commit it like that?
no, never pip freeze
just commit after making these changes
you did 50% of what i said to lol
Haha, you can see from your end?
github
I'm I at 100% now?
haha yeah thats everything i said, hows the build going
Let's see now... no cairo in requirements, and no nix file... let's see
it would have started building already
It has...
But still erroneous
yep you have a chonky project
~200mb before build
Haha, I'm a newbie...
you may want to move static files to a storage bucket
I beg your pardon?
most of the size of your project comes from static files
you may want to move them to a storage bucket (like aws s3) to cut down on your projects size
I honestly don't know how to do that... maybe I am not really comprehending what you're saying, @Brody...
That's the new log
oh well
full build logs please
That's the full log, @Brody
no its not
Sorry, how about this one?
Is that full now?
yes, hold on
Okay, thank you.
please follow each step and make the changes in one single commit
lets move away from nixpacks
1. delete the
Procfile
file
2. add a Dockerfile
file with the contents
Okay, I have deleted the Procfile and added the Dockerfile as above:
Can I commit and push?
yes, let me know how it goes
There we go!!!!! 🥳
awsome
And now....
have you generated a domain?
I have clicked on "Add domain"
do you own a custom domain?
I don't own any domain.
show me the domains section of the service settings please
Oh wait, there's something...
cool, it works
the rest is up to you!
But here's how it should look like
this wouldn't be a railway issue anymore
but heres some starting points
you will want to look into using whitenoise.
railway's django template that uses whitenoise
https://github.com/railwayapp-templates/django
and the docs for whitenoise
https://whitenoise.readthedocs.io/en/latest/django.html
happy coding!
I usually appears like this if the environment is not on on...
But when it's live, it appear like the other one...
So I wonder where the issue would be now that it's live on railway
see my messages above
Okay, let me follow the docs
Or is that right?
I have tried to follow the whitenoise, and now redeploying..
It has worked, @Brody 🥳
Wow
Thank you so much, Sir...
I am much obliged to you, Sir.
Now, this happens when I click register/login...
I have solved it... the system is now working well...
Just one more thing, when I upload data, where is my DB?
remember when I said this?
please share how you solved it for anyone in the future who might have the same problems?
Sure, I can always share, @Brody.
Okay, so how would I go about the DB then?
use the postgre database railway provides as a plugin
1. add the postgre database to your project
2. setup the variable references
https://docs.railway.app/develop/variables#reference-variables
3. reference railway's django template because it uses a postgre database
https://github.com/railwayapp-templates/django
Okay, I would check that when I login to that system.
Now, I am trying to deploy another system, but after it deploys, and I load the site, it says "App crashed", and then on the deploy logs, it says:
/bin/bash: line 1: guinicorn: command not found
/bin/bash: line 1: guinicorn: command not found
/bin/bash: line 1: guinicorn: command not found
What could be the problem, please?
https://github.com/DenzelGitonga007/Point-of-Sale
That's the link to the repo...
GitHub
GitHub - DenzelGitonga007/Point-of-Sale: A Point of Sale System bui...
A Point of Sale System built in Django, that'll allow shops to manage stores, have an inventory, and perform sales of their products at the cashier's desk. - GitHub - DenzelGitonga0...
Yet my Procfile has:
web: gunicorn django_pos.wsgi --log-file -
I see you added gunicorn to your requirements.txt file, that was what I was gonna suggest, did it solve it?
No, not really...
I actually decided to start the project all over again...
Let me let you know how it goes, okay?
sounds good!
Thanks
Hello Sir, how do you do?
I have an enquiry, when using Django for a site that'd be deployed, would you advise using Postgress DB?
Then, for deployment, do I need to to switch the db from the default DBSQLite locally on my machine? Will it reflect on the server where I deploy, like Railway?
for running on railway, yes use postgre, for local sqlite is fine
@Vin mind linking that page that shows how to use different databases for different environments?
Yeah, let me find it again
How to automatically switch debug/production database in settings.p...
Since settings.py is just an ordinary Python file we can use simple
if else
block.perfect, thanks
No problem
Hello everyone, how's it going?
Thank you so much for your continued support, you have been outstandingly helpful.
For the database, perhaps I'll check it out when I reach the last phases of the project I'm working on.
,the which is However, I have encountered a deployment error, on my clarion-stationers website, still hosted on railway.
Now, the site was working fine and well, but upon installing a library for printing receipts, the site builds, and even deploys, but upon accessing it, it says that the application failed to respond, and when I check the deploy logs, I see it start falling from the weasyprint point.
However, I have another site using weasyprint, and it's working just well, I don't know why this one doesn't seem to be working.
I have attached the logs, perhaps you could have a look and help me fix the issue, please.
Thank you.
hey, please refrain from pinging helpers in here 🙂
Oh, alright, my apologies for that.
very recently someone else has made a help thread about weasyprint not working with the same error message, and I was unable to solve it for them, so sorry I don't know how to help you with that
Oh my, is there nothing that can be done?
I'm not a django or even python developer for that matter, I am out of ideas, but you are welcome to Google around
here is that thread: https://discord.com/channels/713503345364697088/1117364822879764490
Oh, thanks guys, I actually resolved to print my receipt (which was what Weasyprint was doing), in another way that is now working even on Railway.
I am grateful for your assistance.
Thank you once again.
awsome, the less external dependencies the better
Hello, how do you do?
If I use this in the settings.py, if I push to railway, will it automatically take effect? Also, if I push another time, will it overwrite the existing items on the db?
I think I am having a challenge switching to postgress
On the railway platform. like I don't know how it
It's done*
If you are going to use Postgres, your settings file should look similar to this one
https://GitHub.com/railwayapp-templates/django
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.
This is a good starting point to get your app up and running. Afterwards, you can add the local dev database following the article I provided the other day. Your migrations will automatically take place based on the start command in the railway.json file anytime you push changes to your code
You would wrap the database connections in an if statement, and before you push to railway, you want to modify settings.py to be DEBUG=False
That way it will connect to the railway hosted Postgres database
Alright, let me try and let you know... thank you.
No problem
Hello, how do you do?
Would I politely ask, I thought Railway provides free hosting and usage... I have deployed to systems on Railway following this, but now I am getting the message "The Starter plan will be discontinued on August 1, 2023. Upgrade to the Hobby plan to continue using Railway."...
Would someone please explain whether I'll be charged for the projects, as my sole intention was to have the free plan.
Thank you.
Refer to dedicated ticket; https://discord.com/channels/713503345364697088/1125710821494882334
Thank you