mine is a react app (not build from creat react app) we use env file for different environments variables(use Dotenv web pack ) from npm . We are deploying this app to docker container in kubernetes. Looking for a way that env vars can be managed from kubernetes side than from .env file . While running In localhost (not in docker ) it should work also when deploying should take from kubernetes.any suggestion
You can use configmap
and secrets
in kubernetes to manage the environment variables. while both are default in kubernetes so no need of extra installation.
there are many other option you can also use the hashicorp vault
for more secure varible store.
if you want to set the environment variables in docker file include you can do it like
...
RUN npm run build
ENV File_location=/app/.env
ENV DB_PORT=9090
WORKDIR /
RUN npm install express
...
This environment variable you can use and import to code.