R
Railway10mo ago
mikha

Fontconfig to canvas

Hi, I've been using the node-canvas in default railway when I use that, only libuuid and libGL are installed, through libs like: fontconfig. Do you have any option to install the fontconfig lib without create a custom Dockerfile? cattroll 4b5e343b-a630-49ff-8375-74a2e5bba62c
49 Replies
Percy
Percy10mo ago
Project ID: 4b5e343b-a630-49ff-8375-74a2e5bba62c
mikha
mikha10mo ago
4b5e343b-a630-49ff-8375-74a2e5bba62c
Brody
Brody10mo ago
give this nixpacks.toml file a shot
[phases.setup]
nixPkgs = ['...', 'fontconfig']
[phases.setup]
nixPkgs = ['...', 'fontconfig']
mikha
mikha10mo ago
Can I follow these configs in nixpacks.toml to do commands too?
Brody
Brody10mo ago
explain please
mikha
mikha10mo ago
like a RUN in docker compose RUN yarn lint for example inside a .toml file Do you have a link to toml config file documentation?
mikha
mikha10mo ago
oh great let me see
[phases.build]
cmds = ['yarn run server:build']
[phases.build]
cmds = ['yarn run server:build']
this works I think Thanks! <:LINKSBR_vamo:1047304250096631858>
Brody
Brody10mo ago
no problem
mikha
mikha10mo ago
Works, I installed the libs but in fontconfig specific It return this error: Fontconfig error: Cannot load default config file Do you have any way to config the font path like a: export FONTCONFIG_PATH=/etc/fonts
Brody
Brody10mo ago
install it as an apt package instead
mikha
mikha10mo ago
let me try it
Brody
Brody10mo ago
show me the nixpacks file before you push changes though
mikha
mikha10mo ago
of course
mikha
mikha10mo ago
[phases.setup]
aptPkgs = ["...",'fontconfig', 'freetype']
[phases.setup]
aptPkgs = ["...",'fontconfig', 'freetype']
Let me show you the errors. In upper have the fontconfig error, down bellow has a out of memory error
Brody
Brody10mo ago
what's the out of memory for? you're on the hobby plan, that's 8gb of mem
mikha
mikha10mo ago
Yeah, lol! haha My app uses less 1gb I belive it's because the fontconfig then canvas join in looping
Brody
Brody10mo ago
what kind of app is this
mikha
mikha10mo ago
Is a nestjs app a api to create and handle some images using canvas simple app
Brody
Brody10mo ago
show me the build table at the top of the build logs?
mikha
mikha10mo ago
oh sure:
Brody
Brody10mo ago
have you tried to set any variables related to font config yourself?
mikha
mikha10mo ago
like that, right?
Brody
Brody10mo ago
yeah, have you done that?
mikha
mikha10mo ago
I didn't try let me set this and try again
Brody
Brody10mo ago
you really shouldn't need to I have a canvas project and all I needed to do was install fontconfig as an apt package and it worked are you using node-canvas instead of canvas?
mikha
mikha10mo ago
in package.json
mikha
mikha10mo ago
is only canvas
mikha
mikha10mo ago
GitHub
GitHub - Automattic/node-canvas: Node canvas is a Cairo backed Canv...
Node canvas is a Cairo backed Canvas implementation for NodeJS. - GitHub - Automattic/node-canvas: Node canvas is a Cairo backed Canvas implementation for NodeJS.
mikha
mikha10mo ago
I followed this steps
Brody
Brody10mo ago
that's the same canvas version I use, but I do not have the fontconfig npm package
mikha
mikha10mo ago
I'll remove that because a have the apt fontconfig now
Brody
Brody10mo ago
a guess would be that the npm fontconfig is messing something up
mikha
mikha10mo ago
yeah
Brody
Brody10mo ago
https://github.com/brody192/node-canvas-fonts I install the fontconfig from within the railway.json, but it makes no difference
mikha
mikha10mo ago
O sure let me try
Brody
Brody10mo ago
try what
mikha
mikha10mo ago
uninstall the fontconfig from my npm
Brody
Brody10mo ago
ah okay
mikha
mikha10mo ago
and install with apt Thanks again!
mikha
mikha10mo ago
Fontconfig works now. But the out of memory error still happens. It's crazy because the server memory is bellow than 150mb Is it possible that Node.js has a memory limit inside the container?
Brody
Brody10mo ago
maybe the heap limit or something
mikha
mikha10mo ago
yes, in my local machine run the same build works using 500mb in the max That happens when start a new promise inside canvas, I'll search in canvas issues. Thanks Brody, you helped a lot with fontconfig! OK
Brody
Brody10mo ago
try setting a service variable NODE_OPTIONS = --max-old-space-size=4096
mikha
mikha10mo ago
the error still happen <a:I69_cat_Cry:989322598280224859>
Brody
Brody10mo ago
what version of node do you use locally
mikha
mikha10mo ago
16.16.0 in Win
Brody
Brody10mo ago
railway uses node 16 something by default too so we are back to code issue 🙂
mikha
mikha10mo ago
yeah, I'll check in canvas issues with nest idk... thanks