React side not getting up in the docker

59 Views Asked by At

network-inspectWe had created a docker file with environment variables and not adding arguments directly through build. Instead we add environment variables into the docker file and push those images to the docker and any new users can pull the images directly from the docker and use it while we install the project. The .env files are created by the user in the time of build. But after the docker gets up in the docker desktop by pulling the images directly from docker, it is not redirecting to the browser to access the web side and create forms, it is continuingly looping while we inspect it. Can anyone share a solution for this?

1

There are 1 best solutions below

0
On BEST ANSWER

When you create a React build the environment values get passed which gets binded at build time and the docker image you have build doesnt use any new environment you would pass later . Instead of this try to get the Environment as dynamic Say declaring a config.js file and fetching it from it for the values at runtime. You can update the volume with replacing the file say config.js from the docker container with the new values to be used. Find the new docker-compose file

version: "3.7"

    services:
      forms-flow-web:
        container_name: forms-flow-web
        image: your_image_name_forms-flow-web
        volumes:
          - ./config/config.js:/usr/share/nginx/html/config/config.js
        ports:
          - "3000:8080"
        tty: true

Like this way the new environment values can be updated from existing build.

Note: Creating the config.js and using the environment data to be dynamic at runtime instead of normal env refer here..