How to use dotenv-vault
I have FE (Vite+React) and BE (Node+Express) apps which is deployed on railway. I came across dotenv-vault and wanted to try it out so for my BE I created a custom build command in railway dashbaord, ideally it should fetch
.env.production
file in the repo during build which my app can use later so no need to add environment variables from the dashboard . But it is not working as expected. Attaching Screenshots FYR for BE service.
Build command:
Solution:Jump to solution
if the file is being created then its nothing remotely to do with railway, your code needs to use it
9 Replies
Project ID:
ed9d81eb-a192-462c-8cf6-bf7778244e57
ed9d81eb-a192-462c-8cf6-bf7778244e57
any reason you want to use that over the service variables?
Just wanted to have everything at one place, If I make some changes in my local .env I can make that change directly to .env.production and make sure that it will be taken care of without manucal intervention.
why can't the service variables be your one place?
maybe you are unaware of the
railway run
or railway shell
commands?
https://docs.railway.app/reference/cli-api#run
https://docs.railway.app/reference/cli-api#shellYes it can be but I wanted to explore this one, is it possible?
im sure it can be made to work, but i can only help you with what i know, so im always going to recommend a platform native option first
I believe during build .env.production is getting created, just wanted to make railway know to use that file
Solution
if the file is being created then its nothing remotely to do with railway, your code needs to use it