Environment variables not being injected in NodeJS app
I have a payloadCMS build command that cannot finish with railway even though I added all my .env variables as service variables. For instance I have set NODE_ENV=production, but inside the application there is still NODE_ENV=develop.
Solution:Jump to solution
you need to specify the needed variables via the ARG keyword
https://docs.railway.app/guides/dockerfiles#using-variables-at-build-time...
10 Replies
Project ID:
d426ba88-e4ae-4a98-8b5a-b473f6902b16
d426ba88-e4ae-4a98-8b5a-b473f6902b16
are you building with a dockerfile?
Yes
I use the default docker file
Solution
you need to specify the needed variables via the ARG keyword
https://docs.railway.app/guides/dockerfiles#using-variables-at-build-time
Can you give me an example for NODE_ENV?
ARG NODE_ENV
So all env keys I need to pass to access through ARG.
?
please have a look at the doc section I linked, ENV is not needed here
Thanks! I'm getting somewhere now
I followed a different tutorial which is out of date, because it doesn't use ARG