Pass Docker Env Variables to Vite Containerized Vue.js on Docker Run

Environment variables can only be used in Vue.js applications at build time and the variables are hardcoded in javascript files during build. When you build docker image for the Vue.js application, you use the same image for test and production environments. But the Vue.js application config values can be different in test and production environments. For example: api url configuration value. Since the variables are different in those environments you must pass the configuration values for test and production environments at docker run:...

September 13, 2023 · 4 min · 768 words · CodeGenos