How to properly inject environment variables into Vite React app deployed with Docker Compose? #19200
Unanswered
duonganh203
asked this question in
Q&A
Replies: 1 comment
-
I'm facing same issue. Currently i'm using args to use env Add following in your Dockerfile
And following in compose file
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm deploying a Vite React application using Docker, Docker Compose and Nginx. I have a .env file on my server containing environment variables that I want to inject into my Vite React application.
My setup:
Vite + React frontend
Deployed using Docker and Docker Compose
.env file is stored on the server (in the same folder with docker-compose.yml)
Current docker-compose.yml:
And this is my folder structure &
.env
variable.env file:
The issue is that my Vite React application cannot read the environment variables from the .env file in the production environment. I want to keep the .env file on the server and inject the variables using Docker Compose.
Beta Was this translation helpful? Give feedback.
All reactions