Quasar can't access environment variables in Docker container.



  • I’m using dotenv extension and can read environment variables with process.env
    after starting the client with quasar dev. Quasar can also read them when I build the client with quasar build and then serve it using quasar serve. However if I build and serve the client in docker quasar can no longer read the environment variables. I can confirm that correct environment variables are present inside the container by entering the running container and doing echo $VAR_NAME. What could possible be causing this behavior? Here is my docker compose for the client:

    client:
        container_name: quasar-client
        build:
          context: ./client
        expose:
          - 8080
        environment:
          HOST_SERVER: server
          AUTH0_DOMAIN: "${AUTH0_DOMAIN}"
          AUTH0_CLIENTID: ${AUTH0_CLIENTID}
          AUTH0_AUDIENCE: ${AUTH0_AUDIENCE}
        ports:
          - 80:8080
        depends_on:
          - server
        command: quasar serve dist/spa --hostname 0.0.0.0 --port 8080
    


  • and here is the dockerfile itself:

    FROM node:lts-alpine as build-stage
    WORKDIR /app
    COPY package*.json ./
    RUN npm install -g @quasar/cli
    COPY . .
    RUN npm install
    RUN npm rebuild node-sass
    RUN quasar build
    
    EXPOSE 8080
    CMD ["quasar","serve"]
    

Log in to reply