samedi 17 octobre 2020

How to load the configurations from .env during the app startup?

I have a quasar app that uses DOTENV - Quasar Framework app extension to load configurations from file .env.

When the quasar app gets build, then it will load all the configurations from .env file but I want to load the .env file when the app get started.

The app runs on Kubernetes and all the configurations are stored asConfigMap. During the container startup, I mount the .env file as the following:

      containers:
        - name: argo-ui-test
          image: "example.io/ui/argo-ui-test:0.1.9"
          volumeMounts:
          - name: svc-config-url
            mountPath: /app/.env
            subPath: .env
          imagePullPolicy: Always
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http
          resources:
            {}
      volumes:
        - name: svc-config-url
          configMap:
            name: svc-url

When I look inside the container, the file has been successfully mounted:

drwxr-xr-x 1 root root  4096 Oct 17 10:33 .
drwxr-xr-x 1 root root  4096 Oct 17 10:33 ..
-rw-r--r-- 1 root root    97 Oct 17 10:33 .env
-rw-r--r-- 1 root root   494 Oct  6 09:12 50x.html
drwxr-xr-x 2 root root  4096 Oct 17 09:33 css
-rw-r--r-- 1 root root 16645 Oct 17 09:33 favicon.ico
drwxr-xr-x 2 root root  4096 Oct 17 09:33 fonts
drwxr-xr-x 2 root root  4096 Oct 17 09:33 icons
-rw-r--r-- 1 root root   905 Oct 17 09:33 index.html
drwxr-xr-x 2 root root  4096 Oct 17 09:33 js
I have no name!@argo-ui-test-5c65cb78dc-jnshk:/app$ cat .env
KC_SVC_URL=https://oic.dev.example.io/auth/
USER_SVC_URL=https://user.dev.svc.example.io/api/

The quasar app does not load the configurations from .env file when it starts. What am I doing wrong?




Aucun commentaire:

Enregistrer un commentaire