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:
npx dotenv-vault@latest pull production --dotenvMe=me_key_bla-bla -y
npx dotenv-vault@latest pull production --dotenvMe=me_key_bla-bla -y
No description
No description
Solution:
if the file is being created then its nothing remotely to do with railway, your code needs to use it
Jump to solution
9 Replies
Percy
Percy4mo ago
Project ID: ed9d81eb-a192-462c-8cf6-bf7778244e57
KeshariPiyush224
ed9d81eb-a192-462c-8cf6-bf7778244e57
Brody
Brody4mo ago
any reason you want to use that over the service variables?
KeshariPiyush224
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.
Brody
Brody4mo ago
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#shell
KeshariPiyush224
Yes it can be but I wanted to explore this one, is it possible?
Brody
Brody4mo ago
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
KeshariPiyush224
I believe during build .env.production is getting created, just wanted to make railway know to use that file
Solution
Brody
Brody4mo ago
if the file is being created then its nothing remotely to do with railway, your code needs to use it
Want results from more Discord servers?
Add your server