Pass environment variables from docker-compose to vue app with nginx Pass environment variables from docker-compose to vue app with nginx vue.js vue.js

Pass environment variables from docker-compose to vue app with nginx


In vue js apps you need to pass the env variables as VUE_APP_so in your case it should be VUE_APP_FIRST_ENV_VAR


You can try this. The value of FIRST_ENV_VAR inside docker will be set to the value of FIRST_ENV_VAR_ON_HOST on your host system.

version: '3.6'services:  app:    image: myRegistry/myProject:tag    restart: always    environment:      - FIRST_ENV_VAR=$FIRST_ENV_VAR_ON_HOST      - SECOND_ENV_VAR=$SECOND_ENV_VAR_ON_HOST    ports:      - 8080:8080


Based on this https://medium.com/@rakhayyat/vuejs-on-docker-environment-specific-settings-daf2de660b9, I have made a silly npm package that help to acomplish what you want.

Go to https://github.com/juanise/jvjr-docker-env and take a look to README file.

Basically just run npm install jvjr-docker-env. A new Dockerfile, entrypoint and json file will be added to your project.

Probably you will need to modify some directory and/or file name in Dockerfile in order to work.