R
Railway•15mo 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
Percy•15mo ago
Project ID: 4b5e343b-a630-49ff-8375-74a2e5bba62c
mikha
mikha•15mo ago
4b5e343b-a630-49ff-8375-74a2e5bba62c
Brody
Brody•15mo ago
give this nixpacks.toml file a shot
[phases.setup]
nixPkgs = ['...', 'fontconfig']
[phases.setup]
nixPkgs = ['...', 'fontconfig']
mikha
mikha•15mo ago
Can I follow these configs in nixpacks.toml to do commands too?
Brody
Brody•15mo ago
explain please
mikha
mikha•15mo 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
mikha•15mo 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
Brody•15mo ago
no problem
mikha
mikha•15mo 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
Brody•15mo ago
install it as an apt package instead
mikha
mikha•15mo ago
let me try it
Brody
Brody•15mo ago
show me the nixpacks file before you push changes though
mikha
mikha•15mo ago
of course
mikha
mikha•15mo 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
Brody•15mo ago
what's the out of memory for? you're on the hobby plan, that's 8gb of mem
mikha
mikha•15mo ago
Yeah, lol! haha My app uses less 1gb I belive it's because the fontconfig then canvas join in looping
Brody
Brody•15mo ago
what kind of app is this
mikha
mikha•15mo ago
Is a nestjs app a api to create and handle some images using canvas simple app
Brody
Brody•15mo ago
show me the build table at the top of the build logs?
mikha
mikha•15mo ago
oh sure:
Brody
Brody•15mo ago
have you tried to set any variables related to font config yourself?
mikha
mikha•15mo ago
like that, right?
Brody
Brody•15mo ago
yeah, have you done that?
mikha
mikha•15mo ago
I didn't try let me set this and try again
Brody
Brody•15mo 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
mikha•15mo ago
in package.json
mikha
mikha•15mo ago
is only canvas
mikha
mikha•15mo 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
mikha•15mo ago
I followed this steps
Brody
Brody•15mo ago
that's the same canvas version I use, but I do not have the fontconfig npm package
mikha
mikha•15mo ago
I'll remove that because a have the apt fontconfig now
Brody
Brody•15mo ago
a guess would be that the npm fontconfig is messing something up
mikha
mikha•15mo ago
yeah
Brody
Brody•15mo ago
https://github.com/brody192/node-canvas-fonts I install the fontconfig from within the railway.json, but it makes no difference
mikha
mikha•15mo ago
O sure let me try
Brody
Brody•15mo ago
try what
mikha
mikha•15mo ago
uninstall the fontconfig from my npm
Brody
Brody•15mo ago
ah okay
mikha
mikha•15mo ago
and install with apt Thanks again!
mikha
mikha•15mo 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
Brody•15mo ago
maybe the heap limit or something
mikha
mikha•15mo 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
Brody•15mo ago
try setting a service variable NODE_OPTIONS = --max-old-space-size=4096
mikha
mikha•15mo ago
the error still happen <a:I69_cat_Cry:989322598280224859>
Brody
Brody•15mo ago
what version of node do you use locally
mikha
mikha•15mo ago
16.16.0 in Win
Brody
Brody•15mo ago
railway uses node 16 something by default too so we are back to code issue 🙂
mikha
mikha•15mo ago
yeah, I'll check in canvas issues with nest idk... thanks
Want results from more Discord servers?
Add your server