Node version
Im updating my cms directus to the last version "10.2.1" that version only runs with node LTS 18.16.0
so in my package.json I added also
But when trying to build seems docker doesn't have that node version.
How I can configure railways to use that node version?
error:
Project id: 151b2302-1f55-438d-9d30-a2d6311ce39d
Thanks
91 Replies
Project ID:
151b2302-1f55-438d-9d30-a2d6311ce39d
nixpacks only parses major versions from
engines.node
eg. 16
or 18
so 18.16.0
turns into 18
then nixpacks uses whatever node 18 version is available in the nix packagesthis behavior is specfiied in the nixpacks docs here
https://nixpacks.com/docs/providers/node#setup
to use a very specific node version, i recommend using a dockerfile, where you can specify the base image to use the exact node version of your choosing eg.
FROM node:18.16.0-slim
I don't plan to use docker on this project is a monorepo where one of the apps is hosted on railways and the rest are vercel apps, I can even move it to a new repo but avoid these headeaches was the reason for the team using railway instead of aws. There is a simple docker file template where I can just specify the node version?
is kind of crazy the lts version is not supported by default
you dont need to use docker, the dockerfile is only for railway, and there are plenty of great node dockerfiles floating around on the interwebs 🙂
you just place the dockerfile in the subfolder that is your railway app
sorry Im not very familiar with dockerfiles + the specifics of railway we are just starting using it.
Can you provide me a template I can include on the root of the project?
I clicked on "ask an eng" on the railway interface but probably that would take longer
*talk to an engineer"
it would be quite hard to make you a dockerfile without seeing your repo, could you link your repo?
cannot share because is private and have others apps on the monorepo but the code for that one is actually just an npm install I will share here
package.json
the rest I believe doesn't affect basically railways just runs npx directus start which is currently working fine, no specifics things are setup more than env keys on railway side
you will want to switch over to using a postgre database with railway, railway doesnt have persistent storage so every deploy will wipe your sqlite file
yes the project is already setup on production running on railway with postgress
where is your package-lock.json ?
well is probably on the root of monorepo as is using pnpm
give me a second
im gonna write a dockerfile that needs a package-lock file
in that directory
Ok sounds good I will figure out
since installs deps from lockfile is faster
Thanks Brody
the pnpm-lock.yaml is on the root of the project
that doesnt really apply when in a sub directory
will check if there is a pnpm config to generate the lock file on the app directory
just go run
npm i --package-lock-only
in that directory
npm lock file please, i have never used pnpmsadly monorepos are a pain in the ass
^
let me move this app outside of the mono repo, as is giving me more headeaches
whatever works for you
i advise you change
dev:cmd
to start
I was complaining already about being on a monorepo so is a good move
cool yes with the change start will be possible
untested of course, so let me know how that goes
GitHub
GitHub - windranger-io/mantle-cms: Mantle cms
Mantle cms. Contribute to windranger-io/mantle-cms development by creating an account on GitHub.
will add
remember to do this
im just building locally first to check if my config works
the cms service on railway, is it using variable references for the database variables? (do they have a little postgre icon besides the variable names)
yes
is using railway postgress services with internal variables
the variables in your service have the little postgre icon?
yes
perfect!
and basically all pointing to the service ${{Postgres}}
looks good
ok pushed
will do the changes on railway side to point to the new repo and see if trigger now with the dockerfile
and im sure you know this already but since it seems like you are deploying a commercial product on railway, your team will need to be on the team plan
yep we are
we created an org and added credit card I believe we are on the team plan right?
yep
great
also, your package.json still has
sqlite3
but youd need pg
instead afaik
also, also, missing the start script tooI updated the develop branch but seems there is a problem with line 13
COPY --chown=node:node ./
ERROR: failed to solve: dockerfile parse error on line 13: COPY requires at least two arguments, but only one was provided. Destination could not be determined.
oh my bad
seems is missing destination right?
COPY --chown=node:node . ./
technically missing the source, that should work
I did say untested lol 🙂thanks is going
how's it going?
do I need to do something to the variables get on the container?
explain please
all the service variables are injected into the container/deployment as regular environment variables
along with all the railway variables listed in the docs
I have a file like this https://github.com/kadumedim/directus-starter/blob/master/directus.config.js
but seems the container cannot read them
GitHub
directus-starter/directus.config.js at master · kadumedim/directus-...
Contribute to kadumedim/directus-starter development by creating an account on GitHub.
are the environment variables named the same way as they are in your railway service?
yes
and was working without the dockerfile
I don't need to define those variables inside the dockerfile?
you commented out that COPY line??
and added in your own chown command
please revert back to the dockerfile I provided, with this corrected copy command
yes
ok
you still have sqlite as a dependency, you'd need pg instead
ahh is for running locally wouldn't affect
the config file is already setup to be pg
then move sqlite to the dev dependencies, since railway doesn't need to install it
and regardless, you use postgres on railway, so wouldn't you need the
pg
dependency[Error: EACCES: permission denied, mkdir '/app/.cache'] {
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/app/.cache'
}
Node.js v18.16.0
node:internal/process/promises:288
^
[Error: EACCES: permission denied, mkdir '/app/.cache'] {
triggerUncaughtException(err, true /* fromPromise /);
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/app/.cache'
}
Node.js v18.16.0
node:internal/process/promises:288
triggerUncaughtException(err, true / fromPromise */);
^
[Error: EACCES: permission denied, mkdir '/app/.cache'] {
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/app/.cache'
}
Node.js v18.16.0
use that instead
do you have idea why twhen pushing it skipps the build?
do you have any watch paths set?
yes seem was that
was /**
should be just /* ?
you can just remove it
oh builded no log errors but is failing https://mantle-xyz-staging.up.railway.app/
can I see the deploy logs?
The push refers to repository [us-west1-docker.pkg.dev/railway-infra/railway-docker-users/project/151b2302-1f55-438d-9d30-a2d6311ce39d/service/4e0ba9f0-2626-4abc-8cdf-5f86fd998419]
you will want to remove any build or start commands you have in your service settings like that thingy says
ok
also, perhaps your app isn't listening on host 0.0.0.0?
but is that what is making the app fail?
no, it's just making the annoying warning appear
so try this instead of what you have in your config
PUBLIC_URL:
https://${env.RAILWAY_STATIC_URL}
,
okyeah, but try the line I sent instead of yours
will try but I believe is not that as the error page is from directus, so seems is reading the 404 from the app
there's no error page anymore
wait
you are seing that?
but didn't end up deploying
crazy
is running
that means railway made your app live before the app was ready to handle requests, you will want to setup a healthcheck so that railway makes the app live only when it's able to handle requests
https://docs.railway.app/deploy/healthchecks
this way any future deployment will only be made live when the new deployment is ready to handle requests, thus giving you a zero downtime switch over
great worked now I will do it on prod
thanks
sweet
if you have any more questions, feel free to ask, but I will be gone for an hour or so soon
thanks Brody worked on prod