nuxt/framework

Use runtime environnements variables with Docker

ForWarZz opened this issue · 0 comments

Hello !

I have a Nuxt 3 app, with a Docker image. My Nuxt App need some environements variable, like BASE_URL for API calls.
What I want it's to build one time my Nuxt App as Docker Image, and after, define variables in docker-compose.

That's not working currently, so how can I do it ?
Because, now, variables are set only on build time, but I want to be available to set it at runtime, when I'm starting the app.

docker-compose.yml

web:
    container_name: web_app
    networks:
      - internal
    restart: unless-stopped
    build:
      dockerfile: ./Dockerfile
      context: ./web_app
    environment:
      - NUXT_PORT=3000
      - NUXT_HOST=0.0.0.0
      - BASE_URL=http://target_domain:8000/
    expose:
      - 3000

PS: My Nuxt App is in ssr: false

Thanks for reading.

ForWarZz