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