johnbraum
johnbraum

Reputation: 296

Nuxt3 docker-compose and env vars

I am trying to dockerize my Nuxt3 with SSR enabled. Everything works fine, except that the docker container doesn't get the ENV vars I set in my docker-compose file.

So I build my docker image and have these in my nuxt config:

  runtimeConfig: {
    public: {
      blogApiUrl: '',
      blogUrl: '',
    },
  },

And this is the important part of my docker-compose file:

  nuxt:
    container_name: staging-nuxt
    build:
      context: .
    image: my/nuxt
    restart: unless-stopped
    environment:
      NUXT_PUBLIC_BLOG_API_URL: https://staging-api.example.de
      NUXT_PUBLIC_BLOG_URL: https://staging.example.de
    ports:
      - '3000:3000'
    networks:
      - staging-network

Somehow the docker container has the vars when I inspect the container. But the nuxt3 uses still localhost:1337 which is the default.

What am I missing? Do I need to set the envs while building the image? But I want one image for every environment.

Thanks!

Upvotes: 1

Views: 438

Answers (1)

johnbraum
johnbraum

Reputation: 296

Okay, after days of struggeling, I found out that the nuxt-strapi package uses 2 URLs. One for Server and one for client. I needed to set both in the env file.

Upvotes: 1

Related Questions