Fontconfig Error on Railway Deployment
Hello,
I am currently working on a Node.js project that uses
chartjs-node-canvas ^4.1.6
and chartjs-plugin-annotation ^2.2.1
. The project is deployed on Railway.
During the deployment to production, I encountered an error while trying to generate a chart. All letters on the chart were replaced by squares, and the console logged an error: Fontconfig error: Cannot load default config file
.
From my understanding, this error is related to the font configuration in the environment. The Fontconfig library, which is used by Chart.js to render text, seems to be unable to find its configuration file. This suggests that the environment where my application is running does not have Fontconfig installed or properly configured.
My project is hosted on Railway, which runs on Nixpacks (which in turn runs on Docker). However, I don't have direct control over the Dockerfile or the system's package manager. I only have access to the shell.nix and railway.json files.
To try and resolve the issue, I added fontconfig to the nixPkgs
array in the setup phase of my railway.json
file, as shown below:
Despite this, the error persists. I'm unsure if the fontconfig package is being installed correctly or if the configuration is not being loaded as expected.
I would greatly appreciate any assistance or suggestions on how to resolve this issue. If there are any additional details that would be helpful, please let me know.
Thank you in advance for your help.
Solution:Jump to solution
Solved
Dockerfile worked. Here's its code:
```dockerfile
Use an official Node.js 16 runtime as the base image...
12 Replies
Project ID:
a04e5aab-0452-4be2-b078-3e2d1e5a1503
You can always create a dockerfile that installs the required libraries and launches your app. The build system will use your dockerfile to deploy
Will Railway options be ignored then?
Also what about default Railway procedures, will my Dockerfile replace them?
It will deploy your dockerfile however it is written
I understand for now. Will try my luck with the Dockerfile then, thank You!
Here's my
Dockerfile
placed in the main folder of the app. Is it configured properly for Railway standards?
As long as it runs on your system, it will run on Railway. You will just need to create an environment variable on your service called
PORT
and set it to 80
since you are specifying a portCould I just remove the port line?
You can, but then you would need to make sure your code references the $PORT environment variable so it will pick up the port assigned by railway
of course, thank You
Solution
Solved
Dockerfile worked. Here's its code:
Thank You @Vin
No problem