R
Railway12mo ago
konyan

nixpacks.toml setup for node-gd Lib

I am building nodejs app and using node-gd lib. The App is successfully run on My Local Mac OS. I create own nixpack.toml file because I need to install some libs like libgd-dev and deploy in Railway app. The build is successfully published. But when I run the API , i got error at libgb.so.3. When I do googling I found some solution but not working well . here is error msg from Railways logs
libgd.so.3: cannot open shared object file: No such file or directory
libgd.so.3: cannot open shared object file: No such file or directory
the lib I need to install
https://www.npmjs.com/package/node-gd
https://www.npmjs.com/package/node-gd
my custome nixpacks.toml
providers = ["node"]

[phases.setup]
nixLibs = ['...',"python38"]
nixPkgs = ['nodejs', 'yarn']
aptPkgs = ['...','python3','make','g++','libgd-dev','freeglut3']

[phases.install]
cmd = "yarn install"

[phases.start]
cmd = "yarn start"
providers = ["node"]

[phases.setup]
nixLibs = ['...',"python38"]
nixPkgs = ['nodejs', 'yarn']
aptPkgs = ['...','python3','make','g++','libgd-dev','freeglut3']

[phases.install]
cmd = "yarn install"

[phases.start]
cmd = "yarn start"
here is project ID => https://railway.app/project/1c9ac1a8-e3e3-4815-99a2-095c38d371f9
Railway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
10 Replies
Percy
Percy12mo ago
Project ID: 1c9ac1a8-e3e3-4815-99a2-095c38d371f9
Brody
Brody12mo ago
a nixpacks.toml file is additive, meaning that you only need to specify what you want to change, for example nixpacks will automatically install the dependencies therefore you don't need to specify that in your nixpacks.toml so while I think this won't work, this would still be the better way to write that nixpacks.toml
[phases.setup]
nixPkgs = ['...', 'gcc', 'python38']
aptPkgs = ['...', 'libgd-dev', 'freeglut3']
[phases.setup]
nixPkgs = ['...', 'gcc', 'python38']
aptPkgs = ['...', 'libgd-dev', 'freeglut3']
and a note on why I still don't think this would work, nixpacks will install those apt packages, but the library paths dont seem to be updated so the compiler wont find the libraries, in this case i always default to using a docker
konyan
konyanOP12mo ago
let me clean, nixpack.toml and try again. still fail I will try docker way
Brody
Brody12mo ago
sounds good, if you need to go the dockerfile route I could try to write one for you later, may need access to thr repo for that so I can understand whats going on and test the dockerfile I write against your repo
konyan
konyanOP12mo ago
can you support sample docker file with node js support format?
Brody
Brody12mo ago
I currently don't have one on hand as I'm out for lunch, but there are plenty of examples online, all you'd need to do for railway to use a Dockerfile would be to place the Dockerfile at the root of your project
konyan
konyanOP12mo ago
it is OK
FROM node:latest

RUN mkdir /app
WORKDIR /app

RUN apt-get update && \
apt-get install -y libgd-dev && \
apt-get clean

ENV PATH /app/node_modules/.bin:$PATH

COPY package.json package-lock.json /app/
RUN npm install

COPY . /app/
FROM node:latest

RUN mkdir /app
WORKDIR /app

RUN apt-get update && \
apt-get install -y libgd-dev && \
apt-get clean

ENV PATH /app/node_modules/.bin:$PATH

COPY package.json package-lock.json /app/
RUN npm install

COPY . /app/
show i need to add
# Define the command to run the application
CMD ["npm", "start"]
# Define the command to run the application
CMD ["npm", "start"]
Brody
Brody12mo ago
yes you would need a CMD directive
konyan
konyanOP12mo ago
cool working well
Brody
Brody12mo ago
no problem!!
Want results from more Discord servers?
Add your server