Docker application not finding env var set in service's Variables tab
Project ID: 21dcd679-2ad7-463a-81e8-ed549f5d467b
I have a dockerized Vite application that needs to read a var
VITE_MY_ENV_VAR
that i've set to value 'the-value'
in the Variables tab of my Railway app's service. However, the application cannot find the variable during run time (printing it's value with console.log returns undefined
). The application does successfully read the PORT variable automatically set by Railway both at build time (during an EXPOSE $PORT step) and runtime (during gunicorn --host 0.0.0.0 --port $PORT app:app
). What might be causing my application to not find the VITE_MY_ENV_VAR
variable?Solution:Jump to solution
between line 11 and 12 you would need to specify the
VITE_
variables your app needs like this ARG VITE_MY_ENV_VAR
9 Replies
Project ID:
21dcd679-2ad7-463a-81e8-ed549f5d467b
also, my application works fine if i build and run the dockerfile locally
may i ask what gunicorn has to do with vite?
oh sorry. vite is being built to
yarn build
and then served with gunicorn
not the best practice, but it works
here's my dockerfile
Solution
between line 11 and 12 you would need to specify the
VITE_
variables your app needs like this ARG VITE_MY_ENV_VAR
i'll give this a shot
it worked! thanks so much :)
no problem!